Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/followtheprocess/build
Ridiculously easy debug.BuildInfo
https://github.com/followtheprocess/build
Last synced: 24 days ago
JSON representation
Ridiculously easy debug.BuildInfo
- Host: GitHub
- URL: https://github.com/followtheprocess/build
- Owner: FollowTheProcess
- License: mit
- Created: 2024-10-06T15:17:51.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-10-06T15:23:12.000Z (about 1 month ago)
- Last Synced: 2024-10-07T05:42:22.637Z (about 1 month ago)
- Language: Go
- Size: 98.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Build
[![License](https://img.shields.io/github/license/FollowTheProcess/build)](https://github.com/FollowTheProcess/build)
[![Go Reference](https://pkg.go.dev/badge/github.com/FollowTheProcess/build.svg)](https://pkg.go.dev/github.com/FollowTheProcess/build)
[![Go Report Card](https://goreportcard.com/badge/github.com/FollowTheProcess/build)](https://goreportcard.com/report/github.com/FollowTheProcess/build)
[![GitHub](https://img.shields.io/github/v/release/FollowTheProcess/build?logo=github&sort=semver)](https://github.com/FollowTheProcess/build)
[![CI](https://github.com/FollowTheProcess/build/workflows/CI/badge.svg)](https://github.com/FollowTheProcess/build/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/FollowTheProcess/build/branch/main/graph/badge.svg)](https://codecov.io/gh/FollowTheProcess/build)## Project Description
Ridiculously simple Go build info 🛠️
## Installation
```shell
go get github.com/FollowTheProcess/build@latest
```## Quickstart
```go
package mainimport (
"fmt"
"os""github.com/FollowTheProcess/build"
)func main() {
info, ok := build.Info()
if !ok {
fmt.Fprintf(os.Stderr, "could not get build info")
os.Exit(1)
}fmt.Printf("%s\n", info)
}
```Gets you...
```shell
go: go1.23.2
path: github.com/FollowTheProcess/build/cmd/build
os: darwin
arch: amd64
vcs: git
version: (devel)
commit: 5e8b8a68867eff5f754bfecdbc8baeb2c14c711c
dirty: true
time: 2024-10-06T10:39:12Z
main: mod github.com/FollowTheProcess/build (devel)
-buildmode: exe
-compiler: gc
-ldflags: -X main.version=dev
CGO_ENABLED: 0
GOAMD64: v1
```> [!TIP]
> It's also JSON serialisable!```go
package mainimport (
"encoding/json"
"fmt"
"os""github.com/FollowTheProcess/build"
)func main() {
info, _ := build.Info()
if err := json.NewEncoder(os.Stdout).Encode(info); err != nil {
fmt.Fprintf(os.Stderr, "could not write JSON: %v\n", err)
os.Exit(1)
}
}
```Gets you...
```json
{
"main": {
"path": "github.com/FollowTheProcess/build",
"version": "(devel)"
},
"time": "2024-10-06T10:39:12Z",
"settings": {
"-buildmode": "exe",
"-compiler": "gc",
"-ldflags": "-X main.version=dev",
"CGO_ENABLED": "0",
"GOAMD64": "v1"
},
"go": "go1.23.2",
"path": "github.com/FollowTheProcess/build/cmd/build",
"os": "darwin",
"arch": "amd64",
"vcs": "git",
"version": "(devel)",
"dirty": true
}
```### Credits
This package is wholly based on the Go internal implementation of `runtime/debug.BuildInfo`, this is just a slightly nicer wrapper that makes it easier to access common settings