Skip to content
/ print Public

This package makes output in Go a little bit better

License

Notifications You must be signed in to change notification settings

n0ne/print

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Print

GoDoc

Print is a Go package that makes terminal console output a little prettier (-:

Getting Started

Installing

To start using Print, install Go and run go get:

$ go get -u github.com/n0ne/print

This will retrieve the library.

How to use

Print struct

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:

Screenshot 2023-08-30 at 17 54 34

Or you can call Structc() function, which will add some colors to the output:

print.Structc(user)

The output in this case will be:

Screenshot 2023-08-30 at 17 54 50

Print slice

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:

Screenshot 2023-08-30 at 17 55 03

Print error message

Let's add some color to our error message:

  print.Error("Error: something went wrong")

And this you will see in the console:

Screenshot 2023-08-30 at 17 55 10

License

Print source code is available under the MIT License.

About

This package makes output in Go a little bit better

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages