Skip to content

Commit

Permalink
説明書きを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
harakeishi committed Feb 26, 2022
1 parent dd56636 commit 89115bf
Showing 1 changed file with 64 additions and 1 deletion.
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,73 @@
`curver` was named as an abbreviation for `current version`.

## Table of Contents
- [Installation](#installation)
- [Importing](#importing)
- [Documentation](#documentation)
- [usage](#usage)
- [normal](#normal)
- [use goreleaser](#use-goreleaser)
- [License](#license)

# Installation
```bash
go get github.com/harakeishi/curver
```

# Importing
```go
import (
"github.com/harakeishi/curver"
)
```

# Documentation
Visit the docs on [GoDoc](https://pkg.go.dev/github.com/harakeishi/curver)

# usage
If the value using ldflag is stored in the variable Version, that value will be displayed.
Otherwise, it will display the build information embedded in the running binary.

## normal
```go
// main.go
package main

import (
"github.com/harakeishi/curver"
)

func main () {
curver.EchoVersion()
}
```

``` bash
$ go build -ldflags '-X github.com/harakeishi/curver.Version=v0.1.0' -o ./main
```

This will display the following format.

```bash
$ ./main
version: v0.1.0
```

If you want to embed the result of 'git tag', you can do the following

```
$ go build -ldflags "-X github.com/harakeishi/curver.Version=$(git describe --tags)" -o ./cmds
```
## use goreleaser
If you are using [goreleaser](https://goreleaser.com/) to do the release, do the following

```yml
builds:
- eldflags:
- -s -w -X github.com/harakeishi/curver.Version={{.Version}}

```

# License
[MIT](LICENSE)
Copyright (c) 2022 harakeishi
Licensed under [MIT](LICENSE)

0 comments on commit 89115bf

Please sign in to comment.