Skip to content

olenindenis/go-version

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published