Documentation
¶
Index ¶
- Variables
- func Base64(s string) []byte
- func Circular(path ...interface{}) interface{}
- func Duration(s string) time.Duration
- func F(v interface{}) string
- func FixNestedStyle(s string) string
- func Format(ts []*Token, theme Theme) string
- func GetPrivateField(v reflect.Value, i int) reflect.Value
- func GetPrivateFieldByName(v reflect.Value, name string) reflect.Value
- func JSONBytes(v interface{}, raw string) []byte
- func JSONStr(v interface{}, raw string) string
- func P(values ...interface{}) error
- func Plain(v interface{}) string
- func Ptr(v interface{}) interface{}
- func StripANSI(str string) string
- func Stylize(s Style, str string) string
- func Time(s string, monotonic int) time.Time
- func VisualizeANSI(str string) string
- type Any
- type Arr
- type Obj
- type Style
- type Theme
- type Token
- type Type
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Bold style Bold = Style{"\x1b[1m", "\x1b[21m"} // Faint style Faint = Style{"\x1b[2m", "\x1b[22m"} // Italic style Italic = Style{"\x1b[3m", "\x1b[23m"} // Underline style Underline = Style{"\x1b[4m", "\x1b[24m"} // Black color Black = Style{"\x1b[30m", "\x1b[39m"} // Red color Red = Style{"\x1b[31m", "\x1b[39m"} // Green color Green = Style{"\x1b[32m", "\x1b[39m"} // Yellow color Yellow = Style{"\x1b[33m", "\x1b[39m"} // Blue color Blue = Style{"\x1b[34m", "\x1b[39m"} // Magenta color Magenta = Style{"\x1b[35m", "\x1b[39m"} // Cyan color Cyan = Style{"\x1b[36m", "\x1b[39m"} // White color White = Style{"\x1b[37m", "\x1b[39m"} // BgBlack color BgBlack = Style{"\x1b[40m", "\x1b[49m"} // BgRed color BgRed = Style{"\x1b[41m", "\x1b[49m"} // BgGreen color BgGreen = Style{"\x1b[42m", "\x1b[49m"} // BgYellow color BgYellow = Style{"\x1b[43m", "\x1b[49m"} // BgBlue color BgBlue = Style{"\x1b[44m", "\x1b[49m"} // BgMagenta color BgMagenta = Style{"\x1b[45m", "\x1b[49m"} // BgCyan color BgCyan = Style{"\x1b[46m", "\x1b[49m"} // BgWhite color BgWhite = Style{"\x1b[47m", "\x1b[49m"} // None type None = Style{} )
View Source
var LongBytesLen = 16
LongBytesLen is the length of that will be treated as long bytes
View Source
var LongStringLen = 16
LongStringLen is the length of that will be treated as long string
View Source
var NoStyle = func() bool { _, noColor := os.LookupEnv("NO_COLOR") b, _ := exec.Command("tput", "colors").CombinedOutput() n, _ := strconv.ParseInt(strings.TrimSpace(string(b)), 10, 32) return noColor || n == 0 }()
NoStyle respects https://no-color.org/ and "tput colors"
View Source
var Stdout io.Writer = os.Stdout
Stdout is the default stdout for gop.P .
View Source
var ThemeDefault = func(t Type) Style { switch t { case TypeName: return Cyan case Bool, Chan: return Blue case Rune, Byte, String: return Yellow case Number: return Green case Func: return Magenta case Comment: return White case Nil, Error: return Red default: return None } }
ThemeDefault colors for Sprint
View Source
var ThemeNone = func(t Type) Style { return None }
ThemeNone colors for Sprint
Functions ¶
func Circular ¶ added in v0.17.0
func Circular(path ...interface{}) interface{}
Circular reference of the path from the root
func FixNestedStyle ¶ added in v0.24.0
FixNestedStyle like
<red>1<blue>2<cyan>3</cyan>4</blue>5</red>
into
<red>1</red><blue>2</blue><cyan>3</cyan><blue>4</blue><red>5</red>
func GetPrivateField ¶
GetPrivateField via field index TODO: we can use a LRU cache for the copy of the values, but it might be trivial for just testing.
func GetPrivateFieldByName ¶ added in v0.22.2
GetPrivateFieldByName is similar with GetPrivateField
Types ¶
type Type ¶
type Type int
Type of token
const ( // Nil type Nil Type = iota // Bool type Bool // Number type Number // Float type Float // Complex type Complex // String type String // Byte type Byte // Rune type Rune // Chan type Chan // Func type Func // Error type Error // Comment type Comment // TypeName type TypeName // ParenOpen type ParenOpen // ParenClose type ParenClose // Dot type Dot // And type And // SliceOpen type SliceOpen // SliceItem type SliceItem // InlineComma type InlineComma // Comma type Comma // SliceClose type SliceClose // MapOpen type MapOpen // MapKey type MapKey // Colon type Colon // MapClose type MapClose // StructOpen type StructOpen // StructKey type StructKey // StructField type StructField // StructClose type StructClose )
Click to show internal directories.
Click to hide internal directories.