MM-27456: Use reflect-free serialization for hot structs (#15171)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
32b7d2b5f1
Коммит
91a76b2df9
23
vendor/github.com/ttacon/chalk/.gitignore
сгенерированный
поставляемый
Обычный файл
23
vendor/github.com/ttacon/chalk/.gitignore
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,23 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
21
vendor/github.com/ttacon/chalk/LICENSE
сгенерированный
поставляемый
Обычный файл
21
vendor/github.com/ttacon/chalk/LICENSE
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Trey Tacon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
67
vendor/github.com/ttacon/chalk/README.md
сгенерированный
поставляемый
Обычный файл
67
vendor/github.com/ttacon/chalk/README.md
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,67 @@
|
||||
chalk
|
||||
=============
|
||||
|
||||
Chalk is a go package for styling console/terminal output.
|
||||
|
||||
Check out godoc for some example usage:
|
||||
http://godoc.org/github.com/ttacon/chalk
|
||||
|
||||
The api is pretty clean, there are default Colors and TextStyles
|
||||
which can be mixed to create more intense Styles. Styles and Colors
|
||||
can be printed in normal strings (i.e. ```fmt.Sprintf(chalk.Red)```), but
|
||||
Styles, Colors and TextStyles are more meant to be used to style specific
|
||||
text segments (i.e. ```fmt.Println(chalk.Red.Color("this is red")```) or
|
||||
```fmt.Println(myStyle.Style("this is blue text that is underlined"))```).
|
||||
|
||||
Examples
|
||||
=============
|
||||
|
||||
There are a few examples in the examples directory if you want to see a very
|
||||
simplified version of what you can do with chalk.
|
||||
|
||||
The following code:
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ttacon/chalk"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// You can just use colors
|
||||
fmt.Println(chalk.Red, "Writing in colors", chalk.Cyan, "is so much fun", chalk.Reset)
|
||||
fmt.Println(chalk.Magenta.Color("You can use colors to color specific phrases"))
|
||||
|
||||
// You can just use text styles
|
||||
fmt.Println(chalk.Bold.TextStyle("We can have bold text"))
|
||||
fmt.Println(chalk.Underline.TextStyle("We can have underlined text"))
|
||||
fmt.Println(chalk.Bold, "But text styles don't work quite like colors :(")
|
||||
|
||||
// Or you can use styles
|
||||
blueOnWhite := chalk.Blue.NewStyle().WithBackground(chalk.White)
|
||||
fmt.Printf("%s%s%s\n", blueOnWhite, "And they also have backgrounds!", chalk.Reset)
|
||||
fmt.Println(
|
||||
blueOnWhite.Style("You can style strings the same way you can color them!"))
|
||||
fmt.Println(
|
||||
blueOnWhite.WithTextStyle(chalk.Bold).
|
||||
Style("You can mix text styles with colors, too!"))
|
||||
|
||||
// You can also easily make styling functions thanks to go's functional side
|
||||
lime := chalk.Green.NewStyle().
|
||||
WithBackground(chalk.Black).
|
||||
WithTextStyle(chalk.Bold).
|
||||
Style
|
||||
fmt.Println(lime("look at this cool lime text!"))
|
||||
}
|
||||
|
||||
```
|
||||
Outputs
|
||||

|
||||
|
||||
|
||||
WARNING
|
||||
=============
|
||||
|
||||
This package should be pretty stable (I don't forsee backwards incompatible changes), but I'm not making any promises :)
|
||||
162
vendor/github.com/ttacon/chalk/chalk.go
сгенерированный
поставляемый
Обычный файл
162
vendor/github.com/ttacon/chalk/chalk.go
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,162 @@
|
||||
package chalk
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Color represents one of the ANSI color escape codes.
|
||||
// http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||
type Color struct {
|
||||
value int
|
||||
}
|
||||
|
||||
// Value returns the individual value for this color
|
||||
// (Actually it's really just its index in the list
|
||||
// of color escape codes with the list being
|
||||
// [black, red, green, yellow, blue, magenta, cyan, white].
|
||||
func (c Color) Value() int {
|
||||
return c.value
|
||||
}
|
||||
|
||||
// Color colors the foreground of the given string
|
||||
// (whatever the previous background color was, it is
|
||||
// left alone).
|
||||
func (c Color) Color(val string) string {
|
||||
return fmt.Sprintf("%s%s%s", c, val, ResetColor)
|
||||
}
|
||||
|
||||
func (c Color) String() string {
|
||||
return fmt.Sprintf("\u001b[%dm", 30+c.value)
|
||||
}
|
||||
|
||||
// NewStyle creates a style with a foreground of the
|
||||
// color we're creating the style from.
|
||||
func (c Color) NewStyle() Style {
|
||||
return &style{foreground: c}
|
||||
}
|
||||
|
||||
type textStyleDemarcation int
|
||||
|
||||
func (t textStyleDemarcation) String() string {
|
||||
return fmt.Sprintf("\u001b[%dm", t)
|
||||
}
|
||||
|
||||
// A TextStyle represents the ways we can style the text:
|
||||
// bold, dim, italic, underline, inverse, hidden or strikethrough.
|
||||
type TextStyle struct {
|
||||
start, stop textStyleDemarcation
|
||||
}
|
||||
|
||||
// TextStyle styles the given string using the desired text style.
|
||||
func (t TextStyle) TextStyle(val string) string {
|
||||
if t == emptyTextStyle {
|
||||
return val
|
||||
}
|
||||
return fmt.Sprintf("%s%s%s", t.start, val, t.stop)
|
||||
}
|
||||
|
||||
// NOTE: this function specifically does not work as desired because
|
||||
// text styles must be wrapped around the text they are meant to style.
|
||||
// As such, use TextStyle() or Style.Style() instead.
|
||||
func (t TextStyle) String() string {
|
||||
return fmt.Sprintf("%s%s", t.start, t.stop)
|
||||
}
|
||||
|
||||
// NewStyle creates a style starting with the current TextStyle
|
||||
// as its text style.
|
||||
func (t TextStyle) NewStyle() Style {
|
||||
return &style{textStyle: t}
|
||||
}
|
||||
|
||||
// A Style is how we want our text to look in the console.
|
||||
// Consequently, we can set the foreground and background
|
||||
// to specific colors, we can style specific strings and
|
||||
// can also use this style in a builder pattern should we
|
||||
// wish (these will be more useful once styles such as
|
||||
// italics are supported).
|
||||
type Style interface {
|
||||
// Foreground sets the foreground of the style to the specific color.
|
||||
Foreground(Color)
|
||||
// Background sets the background of the style to the specific color.
|
||||
Background(Color)
|
||||
// Style styles the given string with the current style.
|
||||
Style(string) string
|
||||
// WithBackground allows us to set the background in a builder
|
||||
// pattern style.
|
||||
WithBackground(Color) Style
|
||||
// WithForeground allows us to set the foreground in a builder
|
||||
// pattern style.
|
||||
WithForeground(Color) Style
|
||||
// WithStyle allows us to set the text style in a builder pattern
|
||||
// style.
|
||||
WithTextStyle(TextStyle) Style
|
||||
String() string
|
||||
}
|
||||
|
||||
type style struct {
|
||||
foreground Color
|
||||
background Color
|
||||
textStyle TextStyle
|
||||
}
|
||||
|
||||
func (s *style) WithBackground(col Color) Style {
|
||||
s.Background(col)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *style) WithForeground(col Color) Style {
|
||||
s.Foreground(col)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *style) String() string {
|
||||
var toReturn string
|
||||
toReturn = fmt.Sprintf("\u001b[%dm", 40+s.background.Value())
|
||||
return toReturn + fmt.Sprintf("\u001b[%dm", 30+s.foreground.Value())
|
||||
}
|
||||
|
||||
func (s *style) Style(val string) string {
|
||||
return fmt.Sprintf("%s%s%s", s, s.textStyle.TextStyle(val), Reset)
|
||||
}
|
||||
|
||||
func (s *style) Foreground(col Color) {
|
||||
s.foreground = col
|
||||
}
|
||||
|
||||
func (s *style) Background(col Color) {
|
||||
s.background = col
|
||||
}
|
||||
|
||||
func (s *style) WithTextStyle(textStyle TextStyle) Style {
|
||||
s.textStyle = textStyle
|
||||
return s
|
||||
}
|
||||
|
||||
var (
|
||||
// Colors
|
||||
|
||||
Black = Color{0}
|
||||
Red = Color{1}
|
||||
Green = Color{2}
|
||||
Yellow = Color{3}
|
||||
Blue = Color{4}
|
||||
Magenta = Color{5}
|
||||
Cyan = Color{6}
|
||||
White = Color{7}
|
||||
ResetColor = Color{9}
|
||||
|
||||
// Text Styles
|
||||
|
||||
Bold = TextStyle{1, 22}
|
||||
Dim = TextStyle{2, 22}
|
||||
Italic = TextStyle{3, 23}
|
||||
Underline = TextStyle{4, 24}
|
||||
Inverse = TextStyle{7, 27}
|
||||
Hidden = TextStyle{8, 28}
|
||||
Strikethrough = TextStyle{9, 29}
|
||||
|
||||
Reset = &style{
|
||||
foreground: ResetColor,
|
||||
background: ResetColor,
|
||||
}
|
||||
|
||||
emptyTextStyle = TextStyle{}
|
||||
)
|
||||
59
vendor/github.com/ttacon/chalk/doc.go
сгенерированный
поставляемый
Обычный файл
59
vendor/github.com/ttacon/chalk/doc.go
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,59 @@
|
||||
// Package chalk is a package for styling terminal/console output.
|
||||
// There are three main components:
|
||||
//
|
||||
//
|
||||
// Colors
|
||||
//
|
||||
// There are eight default colors: black, red, green, yellow, blue,
|
||||
// magenta, cyan and white. You can use them in two main ways
|
||||
// (note the need for the reset color if you don't use Color()):
|
||||
//
|
||||
// fmt.Println(chalk.Red, "this is red text", chalk.ResetColor)
|
||||
// fmt.Println(chalk.Red.Color("this is red text")
|
||||
//
|
||||
//
|
||||
// TextStyles
|
||||
//
|
||||
// There are seven default text styles: bold, dim, italic, underline,
|
||||
// inverse, hidden and strikethrough. Unlike colors, you should only
|
||||
// really use TextStyles in the following manner:
|
||||
//
|
||||
// fmt.Println(chalk.Bold.TextStyle("this is bold text"))
|
||||
//
|
||||
//
|
||||
// Styles
|
||||
//
|
||||
// Styles are where all the business really is. Styles can have a
|
||||
// foreground color, a background color and a text style (sweet!).
|
||||
// They're also pretty simply to make, you just need a starting point:
|
||||
//
|
||||
// blue := chalk.Blue.NewStyle()
|
||||
// bold := chalk.Bold.NewStyle()
|
||||
//
|
||||
// When a color is your starting point for a style, it will be the
|
||||
// foreground color, when a style is your starting point, well, yeah,
|
||||
// it's your style's text style. You can also alter a style's foreground,
|
||||
// background or text style in a builder-esque pattern.
|
||||
//
|
||||
// blueOnWhite := blue.WithBackground(chalk.White)
|
||||
// awesomeness := blueOnWhite.WithTextStyle(chalk.Underline).WithForeground(chalk.Green)
|
||||
//
|
||||
// Like both Colors and TextStyles you can style specific segments of text
|
||||
// with:
|
||||
//
|
||||
// fmt.Println(awesomeness.Style("this is so pretty!"))
|
||||
//
|
||||
// Like Colors, you can also print styles explicitly, but you'll need to
|
||||
// reset your console's colors with chalk.Reset if you use them this way:
|
||||
//
|
||||
// fmt.Println(awesomeness, "this is so pretty", chalk.Reset)
|
||||
//
|
||||
// Be aware though, that this (second) way of using styles will not add the
|
||||
// text style (as text styles require more specific end codes). So if you want
|
||||
// to fully utilize styles, use myStyle.Style() (unless you only care about
|
||||
// print your text with a specific foreground and background, then printing
|
||||
// the style is awesome too!).
|
||||
//
|
||||
// Have fun!
|
||||
//
|
||||
package chalk
|
||||
Ссылка в новой задаче
Block a user