Skip to content

Commit abe371e

Browse files
committed
all: run "go fix"
1 parent ec92694 commit abe371e

File tree

12 files changed

+16
-25
lines changed

12 files changed

+16
-25
lines changed

armor/armor_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build go1.18
6-
// +build go1.18
76

87
package armor_test
98

cmd/age-inspect/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func main() {
118118
// l is a logger with no prefixes.
119119
var l = log.New(os.Stderr, "", 0)
120120

121-
func errorf(format string, v ...interface{}) {
121+
func errorf(format string, v ...any) {
122122
l.Printf("age-inspect: error: "+format, v...)
123123
l.Printf("age-inspect: report unexpected or unhelpful errors at https://filippo.io/age/report")
124124
os.Exit(1)

cmd/age-keygen/keygen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func convert(in io.Reader, out io.Writer) {
170170
}
171171
}
172172

173-
func errorf(format string, v ...interface{}) {
173+
func errorf(format string, v ...any) {
174174
log.Printf("age-keygen: error: "+format, v...)
175175
log.Fatalf("age-keygen: report unexpected or unhelpful errors at https://filippo.io/age/report")
176176
}

cmd/age/age.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,8 @@ func main() {
156156

157157
safe := true
158158
unsafeShell := regexp.MustCompile(`[^\w@%+=:,./-]`)
159-
for _, arg := range os.Args {
160-
if unsafeShell.MatchString(arg) {
161-
safe = false
162-
break
163-
}
159+
if slices.ContainsFunc(os.Args, unsafeShell.MatchString) {
160+
safe = false
164161
}
165162
if safe {
166163
i := len(os.Args) - flag.NArg()
@@ -316,7 +313,7 @@ func passphrasePromptForEncryption() (string, error) {
316313
p := string(pass)
317314
if p == "" {
318315
var words []string
319-
for i := 0; i < 10; i++ {
316+
for range 10 {
320317
words = append(words, randomWord())
321318
}
322319
p = strings.Join(words, "-")

cmd/age/tui.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ import (
3030
// l is a logger with no prefixes.
3131
var l = log.New(os.Stderr, "", 0)
3232

33-
func printf(format string, v ...interface{}) {
33+
func printf(format string, v ...any) {
3434
l.Printf("age: "+format, v...)
3535
}
3636

37-
func errorf(format string, v ...interface{}) {
37+
func errorf(format string, v ...any) {
3838
l.Printf("age: error: "+format, v...)
3939
l.Printf("age: report unexpected or unhelpful errors at https://filippo.io/age/report")
4040
os.Exit(1)
4141
}
4242

43-
func warningf(format string, v ...interface{}) {
43+
func warningf(format string, v ...any) {
4444
l.Printf("age: warning: "+format, v...)
4545
}
4646

@@ -53,7 +53,7 @@ func errorWithHint(error string, hints ...string) {
5353
os.Exit(1)
5454
}
5555

56-
func printfToTerminal(format string, v ...interface{}) error {
56+
func printfToTerminal(format string, v ...any) error {
5757
return term.WithTerminal(func(_, out *os.File) error {
5858
_, err := fmt.Fprintf(out, "age: "+format+"\n", v...)
5959
return err

extra/age-plugin-pq/plugin-pq.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func convert(in io.Reader, out io.Writer) {
138138
}
139139
}
140140

141-
func errorf(format string, v ...interface{}) {
141+
func errorf(format string, v ...any) {
142142
log.Printf("age-plugin-pq: error: "+format, v...)
143143
log.Fatalf("age-plugin-pq: report unexpected or unhelpful errors at https://filippo.io/age/report")
144144
}

internal/bech32/bech32.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func polymod(values []byte) uint32 {
3737
top := chk >> 25
3838
chk = (chk & 0x1ffffff) << 5
3939
chk = chk ^ uint32(v)
40-
for i := 0; i < 5; i++ {
40+
for i := range 5 {
4141
bit := top >> i & 1
4242
if bit == 1 {
4343
chk ^= generator[i]

internal/format/format.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ func (w *WrappedBase64Encoder) writeWrapped(p []byte) (int, error) {
7777
panic("age: internal error: non-empty WrappedBase64Encoder.buf")
7878
}
7979
for len(p) > 0 {
80-
toWrite := ColumnsPerLine - (w.written % ColumnsPerLine)
81-
if toWrite > len(p) {
82-
toWrite = len(p)
83-
}
80+
toWrite := min(ColumnsPerLine-(w.written%ColumnsPerLine), len(p))
8481
n, _ := w.buf.Write(p[:toWrite])
8582
w.written += n
8683
p = p[n:]
@@ -228,7 +225,7 @@ func (e *ParseError) Unwrap() error {
228225
return e.err
229226
}
230227

231-
func errorf(format string, a ...interface{}) error {
228+
func errorf(format string, a ...any) error {
232229
return &ParseError{fmt.Errorf(format, a...)}
233230
}
234231

internal/format/format_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build go1.18
6-
// +build go1.18
76

87
package format_test
98

plugin/plugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,13 @@ func (p *Plugin) Confirm(prompt, yes, no string) (choseYes bool, err error) {
566566

567567
// fatalInteractf prints the error to stderr and sets the broken flag, so the
568568
// Wrap/Unwrap caller can exit with an error.
569-
func (p *Plugin) fatalInteractf(format string, args ...interface{}) error {
569+
func (p *Plugin) fatalInteractf(format string, args ...any) error {
570570
p.broken = true
571571
fmt.Fprintf(p.stderr, format, args...)
572572
return fmt.Errorf(format, args...)
573573
}
574574

575-
func (p *Plugin) fatalf(format string, args ...interface{}) int {
575+
func (p *Plugin) fatalf(format string, args ...any) int {
576576
fmt.Fprintf(p.stderr, format, args...)
577577
return 1
578578
}

0 commit comments

Comments
 (0)