Documentation
¶
Index ¶
- Variables
- func Base64(s string) []byte
- func Circular(path ...interface{}) interface{}
- func ColorStr(c Color, s string) string
- func Duration(s string) time.Duration
- func F(v interface{}) string
- func Format(ts []*Token, theme func(Type) Color) 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 StripColor(str string) string
- func Time(s string, monotonic int) time.Time
- type Any
- type Arr
- type Color
- type Obj
- type Token
- type Type
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTheme = func(t Type) Color { 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: return Red default: return None } }
DefaultTheme colors for Sprint
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 NoColor = func() bool { _, has := os.LookupEnv("NO_COLOR") return has }()
NoColor respects https://no-color.org/
View Source
var NoTheme = func(t Type) Color { return None }
NoTheme colors for Sprint
View Source
var Stdout io.Writer = os.Stdout
Stdout is the default stdout for gop.P .
View Source
var SupportsColor = func() bool { b, _ := exec.Command("tput", "colors").CombinedOutput() n, _ := strconv.ParseInt(strings.TrimSpace(string(b)), 10, 32) return n > 0 }()
SupportsColor returns true if current shell supports ANSI color
Functions ¶
func Circular ¶ added in v0.17.0
func Circular(path ...interface{}) interface{}
Circular reference of the path from the root
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
func StripColor ¶ added in v0.15.2
StripColor is copied from https://github.com/acarl005/stripansi
Types ¶
type Color ¶
type Color int
Color type
const ( // Black type Black Color = iota + 30 // Red type Red // Green type Green // Yellow type Yellow // Blue type Blue // Magenta type Magenta // Cyan type Cyan // White type White // Forground type Forground // Default type Default // BgBlack type BgBlack // BgRed type BgRed // BgGreen type BgGreen // BgYellow type BgYellow // BgBlue type BgBlue // BgMagenta type BgMagenta // BgCyan type BgCyan // BgWhite type BgWhite // Background type Background // BgDefault type BgDefault // None type None Color = -1 )
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 // 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.