Skip to content

Commit

Permalink
at least keep commit info in go install
Browse files Browse the repository at this point in the history
  • Loading branch information
kucukaslan committed Sep 30, 2023
1 parent 97a1bc5 commit 0c2ab10
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
8 changes: 5 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,25 @@ The following is the list of the flags and their functionalities.


## Installation
### go install
### Binaries
See [Releases](https://github.com/Kucukaslan/todo/releases) page for pre-built binaries.
### Building from source
#### go install

```bash
go install github.com/kucukaslan/todo@latest
```
or for a specific version

```bash
go install github.com/kucukaslan/todo@v0.4.2
go install github.com/kucukaslan/todo@v0.1.4-alpha
```

you can list the available versions with
```bash
go list -m -versions github.com/kucukaslan/todo

```
### Building from source
#### Windows
Download the source code.
Open the directory.
Expand Down
50 changes: 45 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,55 @@ todo -d TODO-Id # delete item
import (
"flag"
"fmt"
"runtime/debug"
)

var (
// Version represents the git tag of a particular release.
version = "v0.0.0"

// GitCommit represents git commit hash of a particular release.
commit = "dev"
date = ""
builtBy = ""
commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value
}
}
}
return ""
}()
date = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.time" {
return setting.Value
}
}
}
return ""
}()
builtBy = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs" {
return setting.Value
}
}
}
return ""
}()

modified = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.modified" {
return setting.Value
}
}
}
return ""
}()
)

func main() {
Expand Down Expand Up @@ -73,7 +112,8 @@ func main() {
}

func printVersion() {
v := version + "-" + commit
fmt.Println("todo ", v, " built on", date," (by Muhammed Can Küçükaslan https://github.com/kucukaslan)")
v := version + "-" + commit
fmt.Println("todo ", v, "built on", date, "(via", builtBy, "; local modification: ", modified, ")")
fmt.Println("There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.")
fmt.Println("~ Muhammed Can Küçükaslan https://github.com/kucukaslan)")
}

0 comments on commit 0c2ab10

Please sign in to comment.