version

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 3 Imported by: 0

README

go-version

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Info

func Info() info

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL