diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 1c2818e..289538a 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -github: carlmjohnson +github: earthboundkid diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 811f9df..5ad50dd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -7,18 +7,11 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: 1.18 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: go mod download - - - name: Test - run: cd test && go test -v ./... + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "stable" + - name: Download modules + run: go mod download + - name: Test + run: cd test && go test -v ./... diff --git a/README.md b/README.md index 70b6a7e..f143f56 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# versioninfo [![GoDoc](https://godoc.org/github.com/carlmjohnson/versioninfo?status.svg)](https://godoc.org/github.com/carlmjohnson/versioninfo) [![Go Report Card](https://goreportcard.com/badge/github.com/carlmjohnson/versioninfo)](https://goreportcard.com/report/github.com/carlmjohnson/versioninfo) +# versioninfo [![GoDoc](https://godoc.org/github.com/earthboundkid/versioninfo?status.svg)](https://godoc.org/github.com/earthboundkid/versioninfo) [![Go Report Card](https://goreportcard.com/badge/github.com/earthboundkid/versioninfo)](https://goreportcard.com/report/github.com/earthboundkid/versioninfo) Importable package that parses `debug.ReadBuildInfo()` for inclusion in your Go application. @@ -12,7 +12,7 @@ package main import ( "fmt" - "github.com/carlmjohnson/versioninfo" + "github.com/earthboundkid/versioninfo/v2" ) func main() { @@ -31,7 +31,7 @@ package main import ( "fmt" - "github.com/carlmjohnson/versioninfo" + "github.com/earthboundkid/versioninfo/v2" ) func main() { @@ -48,7 +48,7 @@ import ( "flag" "fmt" - "github.com/carlmjohnson/versioninfo" + "github.com/earthboundkid/versioninfo/v2" ) func main() { diff --git a/go.mod b/go.mod index 21ab8db..57c6e95 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/carlmjohnson/versioninfo +module github.com/earthboundkid/versioninfo/v2 -go 1.16 +go 1.18 diff --git a/modern.go b/init.go similarity index 86% rename from modern.go rename to init.go index 6746477..1ad8e0f 100644 --- a/modern.go +++ b/init.go @@ -1,5 +1,3 @@ -//go:build go1.18 - package versioninfo import ( @@ -12,6 +10,9 @@ func init() { if !ok { return } + if info.Main.Version != "" { + Version = info.Main.Version + } for _, kv := range info.Settings { if kv.Value == "" { continue diff --git a/legacy.go b/legacy.go deleted file mode 100644 index b8c5fac..0000000 --- a/legacy.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build go1.12 - -package versioninfo - -import "runtime/debug" - -func init() { - info, ok := debug.ReadBuildInfo() - if !ok { - return - } - if info.Main.Version != "" { - Version = info.Main.Version - } -} diff --git a/test/go.mod b/test/go.mod index 45b52f9..74e7d31 100644 --- a/test/go.mod +++ b/test/go.mod @@ -1,10 +1,12 @@ -module github.com/carlmjohnson/versioninfo/test +module github.com/earthboundkid/versioninfo/v2/test -go 1.18 +go 1.22 -require github.com/rogpeppe/go-internal v1.8.1 +toolchain go1.23.2 + +require github.com/rogpeppe/go-internal v1.13.1 require ( - github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect - gopkg.in/errgo.v2 v2.1.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/tools v0.22.0 // indirect ) diff --git a/test/go.sum b/test/go.sum index 3b0a7b0..bbf8fab 100644 --- a/test/go.sum +++ b/test/go.sum @@ -1,13 +1,6 @@ -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/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= -github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= diff --git a/test/revision_test.go b/test/revision_test.go index fde4bc7..6136fb0 100644 --- a/test/revision_test.go +++ b/test/revision_test.go @@ -16,9 +16,9 @@ func Test(t *testing.T) { gomod := ` module main -require github.com/carlmjohnson/versioninfo v0.0.0 +require github.com/earthboundkid/versioninfo/v2 v2.0.0 -replace github.com/carlmjohnson/versioninfo => WORKDIR/.. +replace github.com/earthboundkid/versioninfo/v2 => WORKDIR/.. ` wd, _ := os.Getwd() gomod = strings.Replace(gomod, "WORKDIR", wd, 1) diff --git a/test/testdata/flag.txt b/test/testdata/flag.txt index 9792c60..e9faa9f 100644 --- a/test/testdata/flag.txt +++ b/test/testdata/flag.txt @@ -43,7 +43,7 @@ import ( "flag" "fmt" - "github.com/carlmjohnson/versioninfo" + "github.com/earthboundkid/versioninfo/v2" ) func main() { diff --git a/test/testdata/versioninfo.txt b/test/testdata/versioninfo.txt index fea158c..402167c 100644 --- a/test/testdata/versioninfo.txt +++ b/test/testdata/versioninfo.txt @@ -45,7 +45,7 @@ package main import ( "fmt" - "github.com/carlmjohnson/versioninfo" + "github.com/earthboundkid/versioninfo/v2" ) func main() {