Print is a Go package that makes terminal console output a little prettier (-:
To start using Print, install Go and run go get
:
$ go get -u github.com/n0ne/print
This will retrieve the library.
Create a struct:
type User struct {
Name string
Age int
Email string
}
then create a user:
user := User{
Name: "Alex",
Age: 25,
Email: "test@test.com",
}
Now we can print our user:
print.Struct(user)
The output will be:
Or you can call Structc()
function, which will add some colors to the output:
print.Structc(user)
The output in this case will be:
Let's create a few slices:
sliceInt := []int{1, 2, 3, 4, 5, 6}
sliceString := []string{"Some", "strings", "here"}
sliceDouble := []float64{1.1, 2.2, 3.3}
and print them:
print.Slice(sliceInt)
print.Slice(sliceString)
print.Slice(sliceDouble)
The output for slices will be:
Let's add some color to our error message:
print.Error("Error: something went wrong")
And this you will see in the console:
Print source code is available under the MIT License.