Skip to content

Commit ff3529c

Browse files
authored
Replace deprecated terminal package (#126)
1 parent a200812 commit ff3529c

File tree

7 files changed

+51
-74
lines changed

7 files changed

+51
-74
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ require (
77
github.com/jedib0t/go-pretty/v6 v6.0.5
88
github.com/mattn/go-runewidth v0.0.10
99
github.com/muesli/termenv v0.8.1
10-
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392
11-
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff
10+
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0
11+
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72
1212
)
1313

1414
replace git.iglou.eu/Imported/go-wildcard => github.com/IGLOU-EU/go-wildcard v1.0.1

go.sum

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,10 @@ github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
2020
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
2121
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
2222
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
23-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
24-
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 h1:xYJJ3S178yv++9zXV/hnr29plCAGO9vAFG9dorqaFQc=
25-
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
26-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
2723
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
28-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
29-
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3024
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
31-
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff h1:1CPUrky56AcgSpxz/KfgzQWzfG09u5YOL8MvPYBlrL8=
32-
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
33-
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
34-
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
35-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
25+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
26+
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0 h1:g9s1Ppvvun/fI+BptTMj909BBIcGrzQ32k9FNlcevOE=
27+
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
28+
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 h1:VqE9gduFZ4dbR7XoL77lHFp0/DyDUBKSXK7CMFkVcV0=
29+
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
wildcard "git.iglou.eu/Imported/go-wildcard"
1111
"github.com/jedib0t/go-pretty/v6/table"
1212
"github.com/muesli/termenv"
13-
"golang.org/x/crypto/ssh/terminal"
13+
terminal "golang.org/x/term"
1414
)
1515

1616
var (

mounts.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,43 @@ func unescapeFstab(path string) string {
4848
}
4949
return escaped
5050
}
51+
52+
func byteToString(orig []byte) string {
53+
n := -1
54+
l := -1
55+
for i, b := range orig {
56+
// skip left side null
57+
if l == -1 && b == 0 {
58+
continue
59+
}
60+
if l == -1 {
61+
l = i
62+
}
63+
64+
if b == 0 {
65+
break
66+
}
67+
n = i + 1
68+
}
69+
if n == -1 {
70+
return string(orig)
71+
}
72+
return string(orig[l:n])
73+
}
74+
75+
func intToString(orig []int8) string {
76+
ret := make([]byte, len(orig))
77+
size := -1
78+
for i, o := range orig {
79+
if o == 0 {
80+
size = i
81+
break
82+
}
83+
ret[i] = byte(o)
84+
}
85+
if size == -1 {
86+
size = len(orig)
87+
}
88+
89+
return string(ret[0:size])
90+
}

mounts_darwin.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ func mounts() ([]Mount, []string, error) {
6262
opts += ",nodev"
6363
}
6464

65-
device := intToString(stat.Mntfromname[:])
66-
mountPoint := intToString(stat.Mntonname[:])
67-
fsType := intToString(stat.Fstypename[:])
65+
device := byteToString(stat.Mntfromname[:])
66+
mountPoint := byteToString(stat.Mntonname[:])
67+
fsType := byteToString(stat.Fstypename[:])
6868

6969
if len(device) == 0 {
7070
continue
@@ -93,20 +93,3 @@ func mounts() ([]Mount, []string, error) {
9393

9494
return ret, warnings, nil
9595
}
96-
97-
func intToString(orig []int8) string {
98-
ret := make([]byte, len(orig))
99-
size := -1
100-
for i, o := range orig {
101-
if o == 0 {
102-
size = i
103-
break
104-
}
105-
ret[i] = byte(o)
106-
}
107-
if size == -1 {
108-
size = len(orig)
109-
}
110-
111-
return string(ret[0:size])
112-
}

mounts_freebsd.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,3 @@ func mounts() ([]Mount, []string, error) {
105105

106106
return ret, warnings, nil
107107
}
108-
109-
func byteToString(orig []byte) string {
110-
n := -1
111-
l := -1
112-
for i, b := range orig {
113-
// skip left side null
114-
if l == -1 && b == 0 {
115-
continue
116-
}
117-
if l == -1 {
118-
l = i
119-
}
120-
121-
if b == 0 {
122-
break
123-
}
124-
n = i + 1
125-
}
126-
if n == -1 {
127-
return string(orig)
128-
}
129-
return string(orig[l:n])
130-
}

mounts_openbsd.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,3 @@ func mounts() ([]Mount, []string, error) {
8484

8585
return ret, warnings, nil
8686
}
87-
88-
func intToString(orig []int8) string {
89-
ret := make([]byte, len(orig))
90-
size := -1
91-
for i, o := range orig {
92-
if o == 0 {
93-
size = i
94-
break
95-
}
96-
ret[i] = byte(o)
97-
}
98-
if size == -1 {
99-
size = len(orig)
100-
}
101-
102-
return string(ret[0:size])
103-
}

0 commit comments

Comments
 (0)