Skip to content

Latest commit

 

History

History
52 lines (42 loc) · 1.36 KB

README.md

File metadata and controls

52 lines (42 loc) · 1.36 KB

go-version

License: MIT Go Reference Go Report Card

This package helps to include version info to your go application.

Installation

Make sure that Go is installed on your computer. Type the following command in your terminal:

go get github.com/olenindenis/go-version

After it the package is ready to use.

Import package in your project

Add following line in your *.go file:

import "github.com/olenindenis/go-version"

Usage

Before running your code, you need to run the command:

make build

or create your own as shown in the example:

go build -ldflags=${linker_flags} -o=./main ./main.go
package main

import (
    "encoding/json"
    "log"
    "net/http"

    "github.com/olenindenis/go-version"
)

func main() {
    http.HandleFunc("/version", func (w http.ResponseWriter, r *http.Request) {
        w.Header().Set("Content-Type", "application/json")
        json.NewEncoder(w).Encode(version.Info())
    })
    log.Fatal(http.ListenAndServe(":8080", nil))
}