All Packages
cobra
· β˜• 3 min read
cobra package cobra is command line tool that can be used to build command line tools! installation Get cobra installed go get -u github.com/spf13/cobra/cobra usage cobra init creating a new CLI application is as easy as running cobra init cobra init --pkg-name github.com/gophersumit/mycli This should create new cli application: main root main.go 1 2 3 4 5 6 7 package main import "github.com/gophersumit/mycli/cmd" func main() { cmd.Execute() } root.

flag
· β˜• 2 min read
flag package flag package provides types and functions useful for working with command line flags. installation flag package is part of standard Go library at flag usage Simple usage of flag var variable_name = flag.Type("flag_name", "initial_value", "help_message") flag.Type defines the data type of flag flag.String(), Bool(), Int(), etc. flag_name is used from command line to pass value to flag. initial_value is used to initialize flag to some default value and help_message is used to provide help information to user.

json
· β˜• 2 min read
json package json package is part of Go standard library. It providers useful types and functions that can be used to work with json data and Go data types. installation json package is part of standard Go library at encoding/json usage There are two main operation defined while working with json, Marshaling : Marshaling is conversion of Go data types to json. Unmarshaling : Converting json to Go data type.

fresh
· β˜• 1 min read
fresh package Fresh package is file watcher that rebuilds your project and provide hot-reloading like capability so that you do not have to restart web server again and again. installation go get github.com/pilu/fresh usage Go to project folder and run fresh package source and documentation https://pkg.go.dev/github.com/pilu/fresh?tab=doc