Skip to content

Commit

Permalink
Merge pull request #44 from vmkteam/go1.22
Browse files Browse the repository at this point in the history
Use go 1.22, golangci-lint 1.59.1, linter fixes
  • Loading branch information
sas1024 authored Jun 17, 2024
2 parents 1b12b28 + 7a27d7d commit 9111c09
Show file tree
Hide file tree
Showing 18 changed files with 115 additions and 198 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.20.x'
go-version: '1.22.x'

- uses: actions/checkout@v2

Expand All @@ -48,7 +48,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.20.x'
go-version: '1.22.x'

- name: Build
run: go build -v ./...
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.20.x'
go-version: '1.22.x'
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.54.2
version: v1.59.1

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20.x'
go-version: '1.22.x'
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
Expand Down
58 changes: 34 additions & 24 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,46 @@ run:
# include test files or not, default is true
tests: true

# skip files
skip-files:
issues:
# Which files to exclude: they will be analyzed, but issues from them won't be reported.
# There is no need to include all autogenerated files,
# we confidently recognize autogenerated files.
# If it's not, please let us know.
# "/" will be replaced by current OS file path separator to properly work on Windows.
# Default: []
exclude-files:
- ".*\\_gen\\.go$"

output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
# The formats used to render issues.
# Formats:
# - `colored-line-number`
# - `line-number`
# - `json`
# - `colored-tab`
# - `tab`
# - `html`
# - `checkstyle`
# - `code-climate`
# - `junit-xml`
# - `github-actions`
# - `teamcity`
# - `sarif`
# Output path can be either `stdout`, `stderr` or path to the file to write to.
#
# Default:
# formats:
# - format: colored-line-number
# path: stdout
formats:
- format: colored-line-number

# print lines of code with issue, default is true
# Print lines of code with issue.
# Default: true
print-issued-lines: true

# print linter name in the end of issue text, default is true
# Print linter name in the end of issue text.
# Default: true
print-linter-name: true

linters-settings:
Expand All @@ -32,32 +60,14 @@ linters-settings:
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
enabled-checks:
- appendAssign
- appendCombine
- assignOp
- badCond
- boolExprSimplify
- captLocal
- caseOrder
- defaultCaseOrder
- dupArg
- dupBranchBody
- dupCase
- dupSubExpr
- elseif
- emptyFallthrough
- emptyStringTest
- equalFold
- exitAfterDefer
- flagName
- hexLiteral
- indexAlloc
- nilValReturn
- offBy1
- regexpMust
- sloppyLen
- switchTrue
- wrapperFunc
- yodaStyleExpr

linters:
Expand Down
2 changes: 1 addition & 1 deletion api/api_zenrpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions api/dartclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ func (c *Client) addModel(dc dartClass) {
if len(dc.Parameters) == 0 {
return
}
switch dc.Name {
case "AnyCustomType":
if dc.Name == "AnyCustomType" {
return
}

Expand All @@ -285,8 +284,7 @@ func (c *Client) convertScalar(t, description string) string {
case "boolean":
return "bool"
default:
switch description {
case "AnyCustomType":
if description == "AnyCustomType" {
return "DateTime"
}
return ""
Expand Down
2 changes: 1 addition & 1 deletion api/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s ProjectService) Save() error {
return err
}

//TODO Save translation
// TODO Save translation

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *Server) Serve() error {
rpc.Register(projectNS, NewProjectService(store))
rpc.Register(xmlNS, NewXMLService(store))
rpc.Register(xmlVtNS, NewXMLVTService(store))
//rpc.Register(xmlLangNS, NewXMLLangService(store))
// rpc.Register(xmlLangNS, NewXMLLangService(store))

rpc.Use(ProjectMiddleware(store))

Expand Down
2 changes: 1 addition & 1 deletion api/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (s XMLService) GenerateModelCode(entity mfd.Entity) (string, error) {
//
//zenrpc:entity Entity
func (s XMLService) GenerateSearchModelCode(entity mfd.Entity) (string, error) {
//todo PackSearchEntity panics
// TODO PackSearchEntity panics
ent := model.PackEntity(entity, model.Options{GoPGVer: s.CurrentProject.GoPGVer, CustomTypes: s.CurrentProject.CustomTypes})
tpl := template.Must(template.New("tmp").Parse(searchTemplate))
var b bytes.Buffer
Expand Down
2 changes: 1 addition & 1 deletion generators/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ type AttributeData struct {
mfd.Attribute

Name string
//Type string
// Type string
Import string

Tag template.HTML
Expand Down
6 changes: 3 additions & 3 deletions generators/testdata/expected/vt/portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (s CategoryService) isValid(ctx context.Context, category Category, isUpdat
return v
}

//custom validation starts here
// custom validation starts here
return v
}

Expand Down Expand Up @@ -377,7 +377,7 @@ func (s NewsService) isValid(ctx context.Context, news News, isUpdate bool) Vali
v.Append("tagIds", FieldErrorIncorrect)
}
}
//custom validation starts here
// custom validation starts here
return v
}

Expand Down Expand Up @@ -554,6 +554,6 @@ func (s TagService) isValid(ctx context.Context, tag Tag, isUpdate bool) Validat
return v
}

//custom validation starts here
// custom validation starts here
return v
}
4 changes: 2 additions & 2 deletions generators/vt-template/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestGenerator_Generate(t *testing.T) {
filepath.Join("Category", "Form.vue"): {},
filepath.Join("News", "components", "MultiListFilters.vue"): {},
filepath.Join("Tag", "components", "MultiListFilters.vue"): {},
filepath.Join("routes.ts"): {},
"routes.ts": {},
}

for f := range expectedFilenames {
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestGenerator_Generate(t *testing.T) {
filepath.Join("Tag", "List.vue"): {},
filepath.Join("Category", "Form.vue"): {},
filepath.Join("Tag", "components", "MultiListFilters.vue"): {},
filepath.Join("routes.ts"): {},
"routes.ts": {},
}

Convey("Check content", func() {
Expand Down
4 changes: 2 additions & 2 deletions generators/vt/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (s {{.Name}}Service) isValid(ctx context.Context, {{.VarName}} {{.Name}}, i
}
{{if .HasAlias}}
//check alias unique
// check alias unique
search := &db.{{.Name}}Search{
{{.AliasArg}}: &{{$model.VarName}}.{{.AliasField}},{{range .PKSearches}}
{{.Arg}}: &{{$model.VarName}}.{{.Field}},{{end}}
Expand Down Expand Up @@ -352,7 +352,7 @@ func (s {{.Name}}Service) isValid(ctx context.Context, {{.VarName}} {{.Name}}, i
}
}
{{end}}{{end}}{{end}}
//custom validation starts here
// custom validation starts here
return v
}
Expand Down
10 changes: 5 additions & 5 deletions generators/xml/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ func (g *Generator) Generate() (err error) {
case quietAll:
if exiting != nil {
namespace = exiting.Namespace
break //case
break // case
}
continue //loop
continue // loop
case quietNew:
if exiting != nil {
namespace = exiting.Namespace
break //case
break // case
}
fallthrough //to default
fallthrough // to default
default:
// asking namespace from prompt
if namespace, err = g.PromptNS(entity.PGFullName, set.Elements()); err != nil {
Expand All @@ -251,7 +251,7 @@ func (g *Generator) Generate() (err error) {
}
// if user choose to skip
if namespace == "skip" {
continue //loop
continue // loop
}
}

Expand Down
2 changes: 1 addition & 1 deletion generators/xml/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func nullable(column model.Column) string {
switch {
case column.IsPK || column.Nullable:
return mfd.NullableYes
//case column.GoType == model.TypeString || column.IsFK:
// case column.GoType == model.TypeString || column.IsFK:
// return mfd.NullableEmpty
default:
return mfd.NullableNo
Expand Down
32 changes: 14 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,47 +1,43 @@
module github.com/vmkteam/mfd-generator

go 1.20
go 1.22

require (
github.com/dizzyfool/genna v1.2.0
github.com/fatih/camelcase v1.0.0
github.com/jinzhu/inflection v1.0.0
github.com/manifoldco/promptui v0.8.0
github.com/smartystreets/goconvey v1.6.4
github.com/spf13/cobra v1.1.3
github.com/vmkteam/zenrpc/v2 v2.2.9
golang.org/x/text v0.4.0
github.com/manifoldco/promptui v0.9.0
github.com/smartystreets/goconvey v1.8.1
github.com/spf13/cobra v1.8.1
github.com/vmkteam/zenrpc/v2 v2.2.11
golang.org/x/text v0.16.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/go-pg/pg/v10 v10.10.5 // indirect
github.com/go-pg/pg/v10 v10.13.0 // indirect
github.com/go-pg/zerochecker v0.2.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
github.com/smarty/assertions v1.15.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/vmihailenco/bufpool v0.1.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.1 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/sys v0.21.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
mellium.im/sasl v0.3.1 // indirect
)
Loading

0 comments on commit 9111c09

Please sign in to comment.