Browse Source

add golangci-lint, fix some things it nailed

Signed-off-by: Erik Hollensbe <github@hollensbe.org>
master
Erik Hollensbe 10 months ago
parent
commit
b93aa14a8f
6 changed files with 39 additions and 9 deletions
  1. +1
    -0
      .gitignore
  2. +22
    -0
      .golangci.yml
  3. +4
    -1
      Makefile
  4. +11
    -0
      box.rb
  5. +0
    -7
      proto/handler.go
  6. +1
    -1
      version/generate.sh

+ 1
- 0
.gitignore View File

@ -10,3 +10,4 @@ version/generated.go
*.pem
*.crt
*.key
.cache

+ 22
- 0
.golangci.yml View File

@ -0,0 +1,22 @@
linters:
disable-all: true
enable:
- goimports
- scopelint
- gocyclo
- deadcode
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- bodyclose
- golint
- misspell
issues:
exclude-use-default: false
run:
deadline: 5m

+ 4
- 1
Makefile View File

@ -14,7 +14,7 @@ DOCKER_CMD := docker run -it \
$(IMAGE_NAME)
release: distclean
GOBIN=${PWD}/build/ldnsd-$$(cat VERSION) VERSION=$$(cat VERSION) make install
GOBIN=${PWD}/build/ldnsd-$$(cat VERSION) VERSION=$$(cat VERSION) make lint install
# FIXME include LICENSE.md
cp README.md example.conf build/ldnsd-$$(cat VERSION)
cd build && tar cvzf ../ldnsd-$$(cat ../VERSION).tar.gz ldnsd-$$(cat ../VERSION)
@ -53,4 +53,7 @@ get-box:
test:
if [ -z "$${IN_DOCKER}" ]; then make build && $(DOCKER_CMD) $(GO_TEST); else $(GO_TEST); fi
lint:
golangci-lint run -v
.PHONY: test

+ 11
- 0
box.rb View File

@ -6,6 +6,9 @@ PROTOC_URL = "https://github.com/protocolbuffers/protobuf/releases/download/
MKCERT_VERSION = "1.4.1"
MKCERT_URL = "https://github.com/FiloSottile/mkcert/releases/download/v#{MKCERT_VERSION}/mkcert-v#{MKCERT_VERSION}-linux-amd64"
GOLANGCI_LINT_VERSION = "1.24.0"
GOLANGCI_LINT_URL = "https://github.com/golangci/golangci-lint/releases/download/v#{GOLANGCI_LINT_VERSION}/golangci-lint-#{GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz"
def download(name, url)
run "curl -sSL -o /#{name} '#{url}'"
yield "/#{name}"
@ -29,6 +32,14 @@ download("mkcert", MKCERT_URL) do |path|
run "mv '#{path}' /usr/local/bin"
end
download("golangci-lint.tar.gz", GOLANGCI_LINT_URL) do |path|
run "mkdir /tmp/golangci-lint"
run "tar xz -C /tmp/golangci-lint --strip-components=1 -f #{path}"
run "mv /tmp/golangci-lint/golangci-lint /usr/local/bin/golangci-lint"
run "chmod 0755 '/usr/local/bin/golangci-lint'"
run "rm -rf /tmp/golangci-lint"
end
run "mkdir /etc/ldnsd && chown 1000:1000 /etc/ldnsd"
env CAROOT: "/etc/ldnsd"


+ 0
- 7
proto/handler.go View File

@ -33,13 +33,6 @@ func fromGRPC(record *Record) *dnsdb.Record {
}
}
func toGRPC(record *dnsdb.Record) *Record {
return &Record{
Host: record.Host,
Address: record.Address,
}
}
// SetA sets a new A record.
func (h *Handler) SetA(ctx context.Context, record *Record) (*empty.Empty, error) {
r := fromGRPC(record)


+ 1
- 1
version/generate.sh View File

@ -1,3 +1,3 @@
#!bash
printf 'package version\nconst Version = "%s"' "${VERSION}" > generated.go
printf 'package version //nolint\nconst Version = "%s"' "${VERSION}" > generated.go

Loading…
Cancel
Save