diff --git a/Makefile b/Makefile index 1b8c0d6..410576c 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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 ./... diff --git a/internal/dns/dns.go b/internal/dns/dns.go index f6c9cea..0c7d368 100644 --- a/internal/dns/dns.go +++ b/internal/dns/dns.go @@ -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 { diff --git a/internal/state/state.go b/internal/state/state.go index 593ea1f..a337c6a 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -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 @@ -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