Add more pre-commit checks for go

This commit is contained in:
Gabriel Augendre 2021-08-21 10:44:33 +02:00
parent 4465be80ea
commit ccce40a90d
6 changed files with 30 additions and 10 deletions

View file

@ -1,4 +1,3 @@
exclude: ^data/(curated|raw)_data
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
@ -9,11 +8,13 @@ repos:
- id: check-xml
- id: check-yaml
- id: end-of-file-fixer
exclude: ^data/(curated|raw)_data
- id: check-merge-conflict
- id: pretty-format-json
args:
- --autofix
- --no-sort-keys
exclude: ^data/(curated|raw)_data
- id: trailing-whitespace
args:
- --markdown-linebreak-ext=md
@ -21,6 +22,12 @@ repos:
rev: v1.42.0
hooks:
- id: golangci-lint
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-beta.4
hooks:
- id: go-fumpt
args:
- -w
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:

View file

@ -9,9 +9,11 @@ import (
"time"
)
var Male = "homme"
var Female = "femme"
var Unknown = "inconnu(e)"
var (
Male = "homme"
Female = "femme"
Unknown = "inconnu(e)"
)
//go:embed curated_data/countries.json
var rawCountries []byte

View file

@ -1,9 +1,10 @@
package data
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestNewInseeData_ValidForeign(t *testing.T) {

6
go.mod
View file

@ -2,4 +2,8 @@ module insee_number_translator
go 1.16
require github.com/stretchr/testify v1.7.0
require (
github.com/kr/pretty v0.1.0 // indirect
github.com/stretchr/testify v1.7.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
)

8
go.sum
View file

@ -1,11 +1,17 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View file

@ -14,7 +14,7 @@ func main() {
}
func PreProcessRawData(sourceFolder, targetFolder string) {
err := os.MkdirAll(targetFolder, 0755)
err := os.MkdirAll(targetFolder, 0o755)
if err != nil {
fmt.Printf("Error, couldn't create target folder %s: %s", targetFolder, err)
return
@ -89,7 +89,7 @@ func preProcessSimpleFile(sourceFileName, targetFileName, codeColumn string) err
return err
}
err = ioutil.WriteFile(targetFileName, itemsJson, 0644)
err = ioutil.WriteFile(targetFileName, itemsJson, 0o644)
if err != nil {
return err
}
@ -146,7 +146,7 @@ func preProcessCountries(sourceFileName, targetFileName string) error {
return err
}
err = ioutil.WriteFile(targetFileName, citiesJson, 0644)
err = ioutil.WriteFile(targetFileName, citiesJson, 0o644)
if err != nil {
return err
}