From a299c9ede7cf1cfec4bc31edcd6daa9cbe1d1a6f Mon Sep 17 00:00:00 2001 From: Noboru Saito Date: Sat, 11 May 2024 22:07:27 +0900 Subject: [PATCH] Fixed the issue using lint --- cmd/csv.go | 2 +- cmd/root.go | 3 +-- go.mod | 4 ++-- go.sum | 7 ++++--- guesswidth.go | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/csv.go b/cmd/csv.go index dbf4be9..e656788 100644 --- a/cmd/csv.go +++ b/cmd/csv.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" ) -// csvCmd represents the csv command +// csvCmd represents the csv command. var csvCmd = &cobra.Command{ Use: "csv", Short: "Output in csv format", diff --git a/cmd/root.go b/cmd/root.go index 2b587dc..ebff081 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" ) -// rootCmd represents the base command when called without any subcommands +// rootCmd represents the base command when called without any subcommands. var rootCmd = &cobra.Command{ Use: "guesswidth", Short: "Guess the width of the column and split it", @@ -71,5 +71,4 @@ func init() { // initConfig reads in config file and ENV variables if set. func initConfig() { - } diff --git a/go.mod b/go.mod index 52d456e..9d0df07 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module github.com/noborus/guesswidth go 1.18 require ( - github.com/mattn/go-runewidth v0.0.14 + github.com/mattn/go-runewidth v0.0.15 github.com/spf13/cobra v1.6.1 ) require ( github.com/inconshreveable/mousetrap v1.0.1 // indirect - github.com/rivo/uniseg v0.2.0 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/spf13/pflag v1.0.5 // indirect ) diff --git a/go.sum b/go.sum index 172ba08..ad5ed7d 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,11 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= diff --git a/guesswidth.go b/guesswidth.go index 85a6d7c..0dedda8 100644 --- a/guesswidth.go +++ b/guesswidth.go @@ -205,7 +205,7 @@ func split(line string, pos []int, trimSpace bool) []string { if trimSpace { columns[n] = strings.TrimSpace(col) } else { - columns[n] = string(col) + columns[n] = col } n++ start = end @@ -217,7 +217,7 @@ func split(line string, pos []int, trimSpace bool) []string { if trimSpace { columns[n] = strings.TrimSpace(col) } else { - columns[n] = string(col) + columns[n] = col } } return columns @@ -268,9 +268,9 @@ func countBlanks(blanks []int, line string) []int { blanks[n] += 1 } - n += 1 + n++ if runewidth.RuneWidth(r) == 2 { - n += 1 + n++ } } return blanks