Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add golines to make target and run it #69

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ GOMODULE=$(shell grep ^module $(ROOT_DIR)/go.mod | awk '{ print $$2 }')
# Set version strings based on git tag and current ref
GO_LDFLAGS=-ldflags "-s -w"

.PHONY: build mod-tidy clean test
.PHONY: build mod-tidy clean format golines test

# Alias for building program binary
build: $(BINARIES)
Expand All @@ -25,6 +25,12 @@ mod-tidy:
clean:
rm -f $(BINARIES)

format:
go fmt ./...

golines:
golines -w --ignore-generated --chain-split-dots --max-len=80 --reformat-tags .

test: mod-tidy
go test -v ./...

Expand Down
9 changes: 7 additions & 2 deletions internal/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ func handleQuery(w dns.ResponseWriter, r *dns.Msg) {
if address.To4() != nil {
// IPv4
a := &dns.A{
Hdr: dns.RR_Header{Name: k, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 999},
A: address,
Hdr: dns.RR_Header{
Name: k,
Rrtype: dns.TypeA,
Class: dns.ClassINET,
Ttl: 999,
},
A: address,
}
m.Answer = append(m.Answer, a)
} else {
Expand Down
9 changes: 7 additions & 2 deletions internal/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ func (s *State) LookupDomain(domainName string) (map[string]string, error) {
}

// LookupNameserverRecord searches the domain nameserver entries for one matching the requested record
func (s *State) LookupNameserverRecord(recordName string) (map[string]string, error) {
func (s *State) LookupNameserverRecord(
recordName string,
) (map[string]string, error) {
ret := map[string]string{}
err := s.db.View(func(txn *badger.Txn) error {
opts := badger.DefaultIteratorOptions
Expand All @@ -139,7 +141,10 @@ func (s *State) LookupNameserverRecord(recordName string) (map[string]string, er
for it.Rewind(); it.Valid(); it.Next() {
item := it.Item()
k := item.Key()
if strings.HasSuffix(string(k), fmt.Sprintf("_nameserver_%s", recordName)) {
if strings.HasSuffix(
string(k),
fmt.Sprintf("_nameserver_%s", recordName),
) {
err := item.Value(func(v []byte) error {
ret[recordName] = string(v)
return nil
Expand Down
Loading