
Security News
Node.js Homepage Adds Paid Support Link, Prompting Contributor Pushback
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
github.com/tuoaitang/gotable
打印CLI表格框架。
直接运行table_test.go
或者参考使用指南
func TestTable(t *testing.T) {
tbl, err := CreateTable(testHeader)
assert.Nil(t, err)
for _, value := range plainData {
err := tbl.AddValue(value)
assert.Nil(t, err)
}
tbl.PrintTable()
}
func TestColorTable(t *testing.T) {
tbl, err := CreateTable(testHeader)
assert.Nil(t, err)
for _, value := range colorData {
err := tbl.AddValue(value)
assert.Nil(t, err)
}
tbl.PrintTable()
}
func TestStructTable(t *testing.T) {
controller := func(field string, val reflect.Value) color.Color {
switch field {
case "Name":
if strings.Contains(val.String(), "c") {
return color.CYAN
}
case "Experience":
if val.Int() > 5 {
return color.MAGENTA
}
case "Salary":
if val.Float() < 1000 {
return color.YELLOW
}
}
return ""
}
tbl, err := CreateTableFromStruct(MyStruct{}, WithColorController(controller))
assert.Nil(t, err)
err = tbl.AddValuesFromSlice(structSliceData)
assert.Nil(t, err)
tbl.PrintTable()
}
1.3 解决打印彩色字符串时,计算长度时错误,表格对不齐
1.4 支持struct slice转table
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
Research
Security News
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.