Skip to content

Commit

Permalink
fix(jzero): fix goVersion template data
Browse files Browse the repository at this point in the history
  • Loading branch information
jaronnie committed Jun 6, 2024
1 parent a128ed0 commit ec4df07
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
Expand Down
27 changes: 26 additions & 1 deletion internal/new/template_data.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
package new

import "github.com/jzero-io/jzero/pkg/mod"
import (
"fmt"
"strings"

"github.com/hashicorp/go-version"
"github.com/jzero-io/jzero/pkg/mod"
)

const (
go1_21_0 = "1.21.0"
)

func newTemplateData() (map[string]interface{}, error) {
goVersion, err := mod.GetGoVersion()
if err != nil {
return nil, err
}

newVersion, err := version.NewVersion(goVersion)
if err != nil {
return nil, err
}

go1210version, err := version.NewVersion(go1_21_0)
if err != nil {
return nil, err
}

if newVersion.LessThan(go1210version) {
split := strings.Split(goVersion, ".")
goVersion = fmt.Sprintf("%s.%s", split[0], split[1])
}

templateData := map[string]interface{}{
"Module": Module,
"APP": AppName,
Expand Down

0 comments on commit ec4df07

Please sign in to comment.