-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move version to package, add version to rwp command
- Loading branch information
1 parent
0929180
commit f035f88
Showing
3 changed files
with
30 additions
and
18 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
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,24 @@ | ||
package version | ||
|
||
import "runtime/debug" | ||
|
||
const toolkitRepo = "github.com/readium/go-toolkit" | ||
|
||
var Version = "unknown" | ||
|
||
func init() { | ||
if info, ok := debug.ReadBuildInfo(); ok { | ||
if info.Main.Path == toolkitRepo && info.Main.Version != "(devel)" { | ||
// This is the toolkit itself | ||
Version = info.Main.Version | ||
} else { | ||
// This is a module that uses the toolkit | ||
for _, dep := range info.Deps { | ||
if dep.Path == toolkitRepo { | ||
Version = dep.Version | ||
break | ||
} | ||
} | ||
} | ||
} | ||
} |