print

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 5 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckString

func CheckString(arg interface{}) bool

func Error

func Error(error string)

func Slice added in v0.2.0

func Slice[T any](s []T)

func Struct

func Struct(strct interface{})

func Structc

func Structc(strct interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL