Documentation ¶
Overview ¶
Package common implements utility functions shared accross the application
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConsoleBold = color.New(color.Bold).SprintFunc()
Console color varables
Functions ¶
func PrettyPrintJSONToConsole ¶
func PrettyPrintJSONToConsole(b []byte)
Pretty print JSON to console for debugging
Only active if debug is true in the .env file:
DEBUG=true
Example ¶
package main import ( "encoding/json" "github.com/mwiater/golangdocker/common" ) func main() { testSlice := []string{"one", "one", "two", "two", "three", "three"} testSlice1 := common.UniqueSlice(testSlice) testSlice2, _ := json.Marshal(testSlice1) common.PrettyPrintJSONToConsole(testSlice2) }
Output: [ "one", "two", "three" ]
func SplitStringLines ¶
Return slice with each line of a multi-line string, splitting on '\n'
Example ¶
package main import ( "fmt" "github.com/mwiater/golangdocker/common" ) func main() { testString := "line 01\nline 02\nline 03" fmt.Println(common.SplitStringLines(testString)) }
Output: [line 01 line 02 line 03]
func UniqueSlice ¶
Return slice with duplicate items removed
Example ¶
package main import ( "fmt" "github.com/mwiater/golangdocker/common" ) func main() { testSlice := []string{"one", "one", "two", "two", "three", "three"} fmt.Println(common.UniqueSlice(testSlice)) }
Output: [one two three]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.