Skip to content

Commit

Permalink
chore(update): update go and golangci-lint (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjoseph08 authored Oct 16, 2024
1 parent e37c383 commit 4cd9a39
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ tags
# End of https://www.gitignore.io/api/go,vim,macos

bin
.idea
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.13.3
1.23.2
60 changes: 49 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
output:
format: tab
linters:
disable-all: true
enable:
- deadcode
- depguard
- dupl
- goconst
- asciicheck
- bodyclose
- copyloopvar
- decorder
- dogsled
- dupword
- err113
- errcheck
- exhaustive
- gocheckcompilerdirectives
- gocritic
- gocyclo
- gofmt
- godot
- goheader
- goimports
- golint
- gosec
- gosimple
- govet
- grouper
- importas
- inamedparam
- ineffassign
- interfacebloat
- misspell
- prealloc
- nosprintfhostport
- perfsprint
- predeclared
- revive
- staticcheck
- stylecheck
- typecheck
- unconvert
- varcheck
- unparam
- unused
- whitespace
linters-settings:
gosec:
excludes:
- G306 # Expect WriteFile permissions to be 0600 or less
issues:
exclude-use-default: false
max-per-linter: 0
Expand All @@ -28,3 +47,22 @@ issues:
- path: _test\.go
linters:
- dupl
- path: create_test.go
text: G404 # Use of weak random number generator
# The tableName struct field is used by go-pg, even if we don't use it
# directly.
- linters:
- unused
text: tableName
# We don't care about any errors from the releaseLock function.
- linters:
- errcheck
source: releaseLock
# We don't care about package comments.
- linters:
- revive
text: package-comments
# We return dynamic errors.
- linters:
- err113
text: do not define dynamic errors
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ language: go
services:
- postgresql
go:
- 1.13.x
- 1.14.x
- 1.15.x
env:
- GO111MODULE=on
- 1.21.x
- 1.22.x
- 1.23.x
install:
- make setup
- make install
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ endif

$(BIN_DIR)/golangci-lint:
@echo "---> Installing linter"
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(BIN_DIR) v1.21.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN_DIR) v1.61.0

.PHONY: test
test:
@echo "---> Testing"
TEST_DATABASE_USER=$(TEST_DATABASE_USER) TEST_DATABASE_NAME=$(TEST_DATABASE_NAME) go test -v . -coverprofile $(COVERAGE_PROFILE)
TEST_DATABASE_USER=$(TEST_DATABASE_USER) TEST_DATABASE_NAME=$(TEST_DATABASE_NAME) go test . -coverprofile $(COVERAGE_PROFILE)
6 changes: 3 additions & 3 deletions create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package migrations

import (
"fmt"
"io/ioutil"
"os"
"path"
"time"
)
Expand Down Expand Up @@ -36,9 +36,9 @@ func init() {
func create(directory, name string) error {
version := time.Now().UTC().Format(timeFormat)
fullname := fmt.Sprintf("%s_%s", version, name)
filename := path.Join(directory, fmt.Sprintf("%s.go", fullname))
filename := path.Join(directory, fullname+".go")

fmt.Printf("Creating %s...\n", filename)

return ioutil.WriteFile(filename, []byte(fmt.Sprintf(template, fullname)), 0644)
return os.WriteFile(filename, []byte(fmt.Sprintf(template, fullname)), 0644)
}
3 changes: 1 addition & 2 deletions create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package migrations

import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"strings"
Expand All @@ -20,7 +19,7 @@ func TestCreate(t *testing.T) {
err := create(tmp, name)
assert.Nil(t, err)

files, err := ioutil.ReadDir(tmp)
files, err := os.ReadDir(tmp)
assert.Nil(t, err)

found := false
Expand Down
29 changes: 25 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
module github.com/robinjoseph08/go-pg-migrations/v3

go 1.13
go 1.23

require (
github.com/fatih/color v1.7.0 // indirect
github.com/git-chglog/git-chglog v0.0.0-20200414013904-db796966b373
github.com/go-pg/pg/v10 v10.5.0
github.com/imdario/mergo v0.3.8 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/goveralls v0.0.6
github.com/stretchr/testify v1.6.1
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/go-pg/zerochecker v0.2.0 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df // indirect
github.com/urfave/cli v1.22.1 // indirect
github.com/vmihailenco/bufpool v0.1.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.0.0-beta.8 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
go.opentelemetry.io/otel v0.13.0 // indirect
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
golang.org/x/net v0.0.0-20201026091529-146b70c837a4 // indirect
golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1 // indirect
golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375 // indirect
gopkg.in/AlecAivazis/survey.v1 v1.8.7 // indirect
gopkg.in/kyokomi/emoji.v1 v1.5.1 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
mellium.im/sasl v0.2.1 // indirect
)
Loading

0 comments on commit 4cd9a39

Please sign in to comment.