From 604345e7c3f3d6dc4fd799bb1bc542462ba6256e Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Tue, 7 Dec 2021 14:13:09 +0100 Subject: [PATCH] Add script to update go modules, add golangci-lint config --- .golangci.yml | 12 ++++++++++++ geoTiles_test.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- shortPath_test.go | 2 +- templateAssets.go | 7 ++++--- updateDeps.sh | 4 ++++ 7 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 .golangci.yml create mode 100755 updateDeps.sh diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..4f6b781 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,12 @@ +run: + timeout: 5m + issue-exit-code: 0 + skip-tests: true + build-tags: + - linux + - libsqlite3 + - sqlite_fts5 +linters: + enable: + - dupl + - gofmt \ No newline at end of file diff --git a/geoTiles_test.go b/geoTiles_test.go index dda8927..4885ee0 100644 --- a/geoTiles_test.go +++ b/geoTiles_test.go @@ -16,7 +16,7 @@ func Test_proxyTiles(t *testing.T) { hc := &fakeHttpClient{ handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("Hello, World!")) + _, _ = w.Write([]byte("Hello, World!")) }), } app.httpClient = hc diff --git a/go.mod b/go.mod index c6720ee..f879956 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.2-0.20210607094911-0487583eca38 github.com/yuin/goldmark-highlighting v0.0.0-20210516132338-9216f9c5aa01 golang.org/x/crypto v0.0.0-20211202192323-5770296d904e - golang.org/x/net v0.0.0-20211205041911-012df41ee64c + golang.org/x/net v0.0.0-20211206223403-eba003a116a9 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/text v0.3.7 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b diff --git a/go.sum b/go.sum index 7285068..4136fb8 100644 --- a/go.sum +++ b/go.sum @@ -635,8 +635,8 @@ golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211205041911-012df41ee64c h1:7SfqwP5fxEtl/P02w5IhKc86ziJ+A25yFrkVgoy2FT8= -golang.org/x/net v0.0.0-20211205041911-012df41ee64c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211206223403-eba003a116a9 h1:HhGRSJWlxVO54+s9MeOVrZrbnwv+6oZQIvsUrMUte7U= +golang.org/x/net v0.0.0-20211206223403-eba003a116a9/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/shortPath_test.go b/shortPath_test.go index b470a52..9b6652f 100644 --- a/shortPath_test.go +++ b/shortPath_test.go @@ -37,7 +37,7 @@ func Test_shortenPath(t *testing.T) { assert.Equal(t, "/s/2", res3) db.spc.Delete("/a") - db.exec("delete from shortpath where id = 1") + _, _ = db.exec("delete from shortpath where id = 1") res4, err := db.shortenPath("/c") require.NoError(t, err) diff --git a/templateAssets.go b/templateAssets.go index 20cb297..d1e8c3e 100644 --- a/templateAssets.go +++ b/templateAssets.go @@ -132,9 +132,10 @@ func (a *goBlog) initChromaCSS() error { } chromaTempFileName := chromaTempFile.Name() // Write the CSS to the file - chromahtml.New( - chromahtml.ClassPrefix("c-"), - ).WriteCSS(chromaTempFile, chromaStyle) + err = chromahtml.New(chromahtml.ClassPrefix("c-")).WriteCSS(chromaTempFile, chromaStyle) + if err != nil { + return err + } // Close the file _ = chromaTempFile.Close() // Compile asset diff --git a/updateDeps.sh b/updateDeps.sh new file mode 100755 index 0000000..0ee2bf9 --- /dev/null +++ b/updateDeps.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +GOFLAGS="-tags=linux,libsqlite3,sqlite_fts5" go get -d $(go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all) +GOFLAGS="-tags=linux,libsqlite3,sqlite_fts5" go mod tidy -compat 1.17 \ No newline at end of file