From 5ed51062458e2f01521d234a4c91a38d373ee566 Mon Sep 17 00:00:00 2001 From: caixw Date: Wed, 28 Feb 2024 11:34:32 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20assert=20?= =?UTF-8?q?=E8=87=B3=20v4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/go.yml | 2 +- ansi/ansi.go | 2 ++ ansi/csi.go | 6 ++++-- ansi/csi_test.go | 4 +++- ansi/writer.go | 2 ++ ansi/writer_test.go | 2 ++ colors/colorize.go | 2 ++ colors/colorize_test.go | 4 +++- colors/colors.go | 2 ++ colors/colors_test.go | 4 +++- colors/colors_windows.go | 2 ++ colors/fmt.go | 14 ++++++++------ colors/fmt_test.go | 7 ++++--- doc.go | 2 ++ go.mod | 8 ++++---- go.sum | 16 ++++++++-------- prompt/prompt.go | 2 ++ prompt/prompt_test.go | 8 +++++--- prompt/w.go | 2 ++ prompt/w_test.go | 4 +++- term.go | 2 ++ term_windows.go | 2 ++ 22 files changed, 68 insertions(+), 31 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index adfa62e..219713a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - go: ['1.18.x', '1.21.x'] + go: ['1.18.x', '1.22.x'] steps: diff --git a/ansi/ansi.go b/ansi/ansi.go index 3e472be..ef11544 100644 --- a/ansi/ansi.go +++ b/ansi/ansi.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT // Package ansi 输出 ansi 控制码 diff --git a/ansi/csi.go b/ansi/csi.go index 110fbbf..73f068f 100644 --- a/ansi/csi.go +++ b/ansi/csi.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package ansi @@ -7,10 +9,10 @@ import ( "strconv" ) -// ResetCode 重置所有状态的 ansi.ESC 状态码 +// ResetCode 重置所有状态的 [ESC] 状态码 const ResetCode = 0 -// ESC 表示 ansi 转码序列 +// ESC 表示 ANSI 转码序列 type ESC string // F256Color 获取扩展的前景颜色值控制码 diff --git a/ansi/csi_test.go b/ansi/csi_test.go index 5adaffa..76385ae 100644 --- a/ansi/csi_test.go +++ b/ansi/csi_test.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package ansi @@ -6,7 +8,7 @@ import ( "math" "testing" - "github.com/issue9/assert/v3" + "github.com/issue9/assert/v4" ) func TestF256Color(t *testing.T) { diff --git a/ansi/writer.go b/ansi/writer.go index e53c76a..a41e269 100644 --- a/ansi/writer.go +++ b/ansi/writer.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package ansi diff --git a/ansi/writer_test.go b/ansi/writer_test.go index a17333d..77e7408 100644 --- a/ansi/writer_test.go +++ b/ansi/writer_test.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package ansi diff --git a/colors/colorize.go b/colors/colorize.go index 6d41b1a..f6c42ad 100644 --- a/colors/colorize.go +++ b/colors/colorize.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package colors diff --git a/colors/colorize_test.go b/colors/colorize_test.go index 4469ba9..103ef8a 100644 --- a/colors/colorize_test.go +++ b/colors/colorize_test.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package colors @@ -8,7 +10,7 @@ import ( "os" "testing" - "github.com/issue9/assert/v3" + "github.com/issue9/assert/v4" ) func TestColorize_Color(t *testing.T) { diff --git a/colors/colors.go b/colors/colors.go index de01d1a..38536ba 100644 --- a/colors/colors.go +++ b/colors/colors.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT // Package colors 带色彩的控制台文本输出包 diff --git a/colors/colors_test.go b/colors/colors_test.go index 3331ece..63a6437 100644 --- a/colors/colors_test.go +++ b/colors/colors_test.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package colors @@ -5,7 +7,7 @@ package colors import ( "testing" - "github.com/issue9/assert/v3" + "github.com/issue9/assert/v4" ) func TestHEX(t *testing.T) { diff --git a/colors/colors_windows.go b/colors/colors_windows.go index a9c9b3f..54fd5f6 100755 --- a/colors/colors_windows.go +++ b/colors/colors_windows.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package colors diff --git a/colors/fmt.go b/colors/fmt.go index f3ba389..baffde8 100755 --- a/colors/fmt.go +++ b/colors/fmt.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package colors @@ -10,32 +12,32 @@ import ( "github.com/issue9/term/v3/ansi" ) -// Fprint 带色彩输出的 fmt.Fprint +// Fprint 带色彩输出的 [fmt.Fprint] func Fprint(w io.Writer, t Type, foreground, background Color, v ...any) (int, error) { return fmt.Fprint(w, Sprint(t, foreground, background, v...)) } -// Fprintln 带色彩输出的 fmt.Fprintln +// Fprintln 带色彩输出的 [fmt.Fprintln] func Fprintln(w io.Writer, t Type, foreground, background Color, v ...any) (int, error) { return fmt.Fprint(w, Sprintln(t, foreground, background, v...)) } -// Fprintf 带色彩输出的 fmt.Fprintf +// Fprintf 带色彩输出的 [fmt.Fprintf] func Fprintf(w io.Writer, t Type, foreground, background Color, format string, v ...any) (int, error) { return fmt.Fprint(w, Sprintf(t, foreground, background, format, v...)) } -// Print 带色彩输出的 fmt.Print +// Print 带色彩输出的 [fmt.Print] func Print(t Type, foreground, background Color, v ...any) (int, error) { return Fprint(os.Stdout, t, foreground, background, v...) } -// Println 带色彩输出的 fmt.Println +// Println 带色彩输出的 [fmt.Println] func Println(t Type, foreground, background Color, v ...any) (int, error) { return Fprintln(os.Stdout, t, foreground, background, v...) } -// Printf 带色彩输出的 fmt.Printf +// Printf 带色彩输出的 [fmt.Printf] func Printf(t Type, foreground, background Color, format string, v ...any) (int, error) { return Fprintf(os.Stdout, t, foreground, background, format, v...) } diff --git a/colors/fmt_test.go b/colors/fmt_test.go index 687d0d5..763c48e 100644 --- a/colors/fmt_test.go +++ b/colors/fmt_test.go @@ -1,14 +1,15 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package colors import ( "fmt" - "io/ioutil" "os" "testing" - "github.com/issue9/assert/v3" + "github.com/issue9/assert/v4" ) func TestFprint(t *testing.T) { @@ -21,7 +22,7 @@ func TestFprint(t *testing.T) { a.NotError(err) a.NotError(f.Close()) - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) a.NotError(err).NotNil(data) a.Contains(string(data), "\033[") // 也包含控制符 } diff --git a/doc.go b/doc.go index 33b4c56..2a538c2 100644 --- a/doc.go +++ b/doc.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT // Package term 各平台的终端处理工具 diff --git a/go.mod b/go.mod index 716f4fe..8357cff 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/issue9/term/v3 require ( - github.com/issue9/assert/v3 v3.1.0 - github.com/issue9/errwrap v0.3.1 - github.com/issue9/sliceutil v0.15.0 - golang.org/x/sys v0.15.0 + github.com/issue9/assert/v4 v4.1.1 + github.com/issue9/errwrap v0.3.2 + github.com/issue9/sliceutil v0.15.1 + golang.org/x/sys v0.17.0 ) go 1.18 diff --git a/go.sum b/go.sum index efffa21..d51fd9f 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ -github.com/issue9/assert/v3 v3.1.0 h1:oxLFXS7QnBKI4lB31pRoYO96yErkWAJtR7iv+LNjAPg= -github.com/issue9/assert/v3 v3.1.0/go.mod h1:yft/uaskRpwQTyBT3n1zRl91SR1wNlO4fLZHzOa4bdM= -github.com/issue9/errwrap v0.3.1 h1:8g4lYJaGnoiXyZ1oZyH/7zPDGgw5RNiE9Q6ri9kE6Z8= -github.com/issue9/errwrap v0.3.1/go.mod h1:HLR0e5iimd2aJXM9YrThOsRj3/6lMtk77lVp7zyvJ4E= -github.com/issue9/sliceutil v0.15.0 h1:E6Xnl3FY5h0ZGNzyx1VEFAfGdParaq/BkX1QQR0uFwI= -github.com/issue9/sliceutil v0.15.0/go.mod h1:n9meV7AamDhmehOBuV4GrxW3yw7O1cZmLx3Xizg1bps= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +github.com/issue9/assert/v4 v4.1.1 h1:OhPE8SB8n/qZCNGLQa+6MQtr/B3oON0JAVj68k8jJlc= +github.com/issue9/assert/v4 v4.1.1/go.mod h1:v7qDRXi7AsaZZNh8eAK2rkLJg5/clztqQGA1DRv9Lv4= +github.com/issue9/errwrap v0.3.2 h1:7KEme9Pfe75M+sIMcPCn/DV90wjnOcRbO4DXVAHj3Fw= +github.com/issue9/errwrap v0.3.2/go.mod h1:KcCLuUGiffjooLCUjL89r1cyO8/HT/VRcQrneO53N3A= +github.com/issue9/sliceutil v0.15.1 h1:mV1VlQSO5E8sh2ab6pypLg7TdgGZlDb30E8quli01xY= +github.com/issue9/sliceutil v0.15.1/go.mod h1:ldun6sT4/bOJxuMtOXhtc6P7GCwE7L+avV86HNks7qk= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/prompt/prompt.go b/prompt/prompt.go index c73eca6..a28c654 100644 --- a/prompt/prompt.go +++ b/prompt/prompt.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT // Package prompt 简单的终端交互界面 diff --git a/prompt/prompt_test.go b/prompt/prompt_test.go index 4d67a13..00a911c 100644 --- a/prompt/prompt_test.go +++ b/prompt/prompt_test.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package prompt @@ -7,7 +9,7 @@ import ( "io" "testing" - "github.com/issue9/assert/v3" + "github.com/issue9/assert/v4" "github.com/issue9/term/v3/colors" ) @@ -21,8 +23,8 @@ func TestNew(t *testing.T) { Equal(p.defaultColor, colors.Red) p = New('x', new(bytes.Buffer), io.Discard, colors.Red) - a.NotNil(p) - a.Equal(p.delim, 'x') + a.NotNil(p). + Equal(p.delim, 'x') } func TestPrompt_String(t *testing.T) { diff --git a/prompt/w.go b/prompt/w.go index 828f93a..be1fcd9 100644 --- a/prompt/w.go +++ b/prompt/w.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package prompt diff --git a/prompt/w_test.go b/prompt/w_test.go index d6d6204..9f4ffc4 100644 --- a/prompt/w_test.go +++ b/prompt/w_test.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package prompt @@ -8,7 +10,7 @@ import ( "testing" "testing/iotest" - "github.com/issue9/assert/v3" + "github.com/issue9/assert/v4" "github.com/issue9/term/v3/colors" ) diff --git a/term.go b/term.go index e9f00ae..267a06c 100644 --- a/term.go +++ b/term.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT //go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd diff --git a/term_windows.go b/term_windows.go index d35854f..a955191 100644 --- a/term_windows.go +++ b/term_windows.go @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: 2014-2024 caixw +// // SPDX-License-Identifier: MIT package term