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

Commit

Permalink
Merge pull request #1 from kachick/better-env
Browse files Browse the repository at this point in the history
Implement version flag
  • Loading branch information
kachick committed Jun 16, 2023
2 parents b26e22f + ceaa32d commit 0383e3b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- run: go build -v
- run: go build -v -race
lint:
runs-on: ubuntu-latest
steps:
Expand Down
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)"
```
14 changes: 14 additions & 0 deletions nix-headbump.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@ package main

import (
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"regexp"
)

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+"("+revision+")")
return
}

path := "default.nix"
isNixFileExist := true
if _, err := os.Stat(path); os.IsNotExist(err) {
Expand Down

0 comments on commit 0383e3b

Please sign in to comment.