Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update go version #10

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions modfile.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package skeletonkit

import (
"errors"
"bytes"
"fmt"
"go/build"
"os/exec"
"strings"

"golang.org/x/mod/modfile"
Expand Down Expand Up @@ -33,12 +33,13 @@ func ModInit(path string) (string, error) {
}

func goVersion() (string, error) {
tags := build.Default.ReleaseTags
for i := len(tags) - 1; i >= 0; i-- {
version := tags[i]
if strings.HasPrefix(version, "go") && modfile.GoVersionRE.MatchString(version[2:]) {
return version[2:], nil
}
var stdout bytes.Buffer
cmd := exec.Command("go", "env", "GOVERSION")
cmd.Stdout = &stdout

if err := cmd.Run(); err != nil {
return "", err
}
return "", errors.New("there are not valid go version")

return strings.TrimPrefix(strings.TrimSpace(stdout.String()), "go"), nil
}
2 changes: 1 addition & 1 deletion testdata/clean-relative.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- go.mod --
module example.com/example

go 1.23
go 1.23.3

-- main.go --
// Code generated from skeletonkit. DO NOT EDIT.
Expand Down
2 changes: 1 addition & 1 deletion testdata/clean.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- example/go.mod --
module example.com/example

go 1.23
go 1.23.3

-- example/main.go --
// Code generated from skeletonkit. DO NOT EDIT.
Expand Down
2 changes: 1 addition & 1 deletion testdata/creatoropts-empty.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func init() {
-- example/go.mod --
module example.com/example

go 1.23
go 1.23.3

-- example/internal/.gitkeep --
-- example/main.go --
Expand Down
2 changes: 1 addition & 1 deletion testdata/creatoropts-policy.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- example/go.mod --
module example.com/example

go 1.23
go 1.23.3

-- example/main.go --
// not overwritten
2 changes: 1 addition & 1 deletion testdata/overwrite-cancel-relative.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- go.mod --
module example.com/example

go 1.23
go 1.23.3

-- main.go --
// not overwritten
2 changes: 1 addition & 1 deletion testdata/overwrite-cancel.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- example/go.mod --
module example.com/example

go 1.23
go 1.23.3

-- example/main.go --
// not overwritten
2 changes: 1 addition & 1 deletion testdata/overwrite-confirm-no-relative.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- go.mod --
module example.com/example

go 1.23
go 1.23.3

-- main.go --
// not overwritten
2 changes: 1 addition & 1 deletion testdata/overwrite-confirm-no.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- example/go.mod --
module example.com/example

go 1.23
go 1.23.3

-- example/main.go --
// not overwritten
2 changes: 1 addition & 1 deletion testdata/overwrite-confirm-yes-relative.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- go.mod --
module example.com/example

go 1.23
go 1.23.3

-- main.go --
// Code generated from skeletonkit. DO NOT EDIT.
Expand Down
2 changes: 1 addition & 1 deletion testdata/overwrite-confirm-yes.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- example/go.mod --
module example.com/example

go 1.23
go 1.23.3

-- example/main.go --
// Code generated from skeletonkit. DO NOT EDIT.
Expand Down
2 changes: 1 addition & 1 deletion testdata/overwrite-force-relative.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- go.mod --
module example.com/example

go 1.23
go 1.23.3

-- main.go --
// Code generated from skeletonkit. DO NOT EDIT.
Expand Down
2 changes: 1 addition & 1 deletion testdata/overwrite-force.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
-- example/go.mod --
module example.com/example

go 1.23
go 1.23.3

-- example/main.go --
// Code generated from skeletonkit. DO NOT EDIT.
Expand Down
2 changes: 1 addition & 1 deletion testdata/templateopts-funcs.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- example/DIFFERENT-GOMOD --
module example.com/example

go 1.23
go 1.23.3

-- example/config.go --
// Code generated from skeletonkit. DO NOT EDIT.
Expand Down
Loading