Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Set revision from the building value
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jun 16, 2023
1 parent 4d8a840 commit ceaa32d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# How to develop

## Setup

1. Install [Nix](https://nixos.org/) package manager
2. Run `nix-shell` or `nix-shell --command 'zsh'`
3. You can use development tools

```console
> nix-shell
(prepared bash)

> go version
go version go1.20.4 linux/amd64

> dprint --version
dprint 0.36.1

> go build -ldflags "-X main.revision=$(git rev-parse --short HEAD)"
```
4 changes: 3 additions & 1 deletion nix-headbump.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import (

const version string = "0.1.0"

var revision string

func main() {
versionFlag := flag.Bool("version", false, "print the version of this program")
flag.Parse()

if *versionFlag {
fmt.Printf("%s\n", version)
fmt.Printf("%s\n", version+"("+revision+")")
return
}

Expand Down

0 comments on commit ceaa32d

Please sign in to comment.