Generic functions that would be handy while building your Golang utility.
This library stands on the shoulders of various libraries built by some awesome folks.
Get the latest version of GoCD sdk using go get
command.
go get github.com/nikhilsbhat/common@latest
Get specific version of the same.
go get github.com/nikhilsbhat/[email protected]
package main
import (
"github.com/nikhilsbhat/common/renderer"
"github.com/sirupsen/logrus"
"log"
"os"
)
type Object struct {
Name string
Date string
}
func main() {
newObject := []Object{
{Name: "nikhil", Date: "01-01-2024"},
{Name: "john", Date: "01-02-2024"},
}
logger := logrus.New()
render := renderer.GetRenderer(os.Stdout, logger, true, true, false, false, false)
if err := render.Render(newObject); err != nil {
log.Fatal(err)
}
}
Above code should generate yaml as below:
---
- Date: 01-01-2024
Name: nikhil
- Date: 01-02-2024
Name: john
More example of the libraries can be found here.