-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use arduino101load/version package to automatically change build version
- Loading branch information
1 parent
2ccbd62
commit fa827ec
Showing
5 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package globals | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/arduino/arduino101load/version" | ||
) | ||
|
||
var ( | ||
// VersionInfo contains all info injected during build | ||
VersionInfo = version.NewInfo(filepath.Base(os.Args[0])) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/arduino/arduino101load | ||
|
||
go 1.19 | ||
|
||
require github.com/mattn/go-shellwords v1.0.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk= | ||
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package version | ||
|
||
import "fmt" | ||
|
||
var ( | ||
defaultVersionString = "0.0.0-git" | ||
versionString = "" | ||
commit = "" | ||
date = "" | ||
) | ||
|
||
// Info is a struct that contains information about the application | ||
type Info struct { | ||
Application string `json:"Application"` | ||
VersionString string `json:"VersionString"` | ||
Commit string `json:"Commit"` | ||
Date string `json:"Date"` | ||
} | ||
|
||
// NewInfo returns a pointer to an updated Info struct | ||
func NewInfo(application string) *Info { | ||
return &Info{ | ||
Application: application, | ||
VersionString: versionString, | ||
Commit: commit, | ||
Date: date, | ||
} | ||
} | ||
|
||
func (i *Info) String() string { | ||
return fmt.Sprintf("%[1]s Version: %[2]s Commit: %[3]s Date: %[4]s", i.Application, i.VersionString, i.Commit, i.Date) | ||
} | ||
|
||
//nolint:gochecknoinits | ||
func init() { | ||
if versionString == "" { | ||
versionString = defaultVersionString | ||
} | ||
} |