all: run "go fix"

This commit is contained in:
Filippo Valsorda
2025-12-25 20:42:59 +01:00
parent ec92694aad
commit abe371e157
12 changed files with 16 additions and 25 deletions

View File

@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build go1.18
// +build go1.18
package armor_test

View File

@@ -118,7 +118,7 @@ func main() {
// l is a logger with no prefixes.
var l = log.New(os.Stderr, "", 0)
func errorf(format string, v ...interface{}) {
func errorf(format string, v ...any) {
l.Printf("age-inspect: error: "+format, v...)
l.Printf("age-inspect: report unexpected or unhelpful errors at https://filippo.io/age/report")
os.Exit(1)

View File

@@ -170,7 +170,7 @@ func convert(in io.Reader, out io.Writer) {
}
}
func errorf(format string, v ...interface{}) {
func errorf(format string, v ...any) {
log.Printf("age-keygen: error: "+format, v...)
log.Fatalf("age-keygen: report unexpected or unhelpful errors at https://filippo.io/age/report")
}

View File

@@ -156,11 +156,8 @@ func main() {
safe := true
unsafeShell := regexp.MustCompile(`[^\w@%+=:,./-]`)
for _, arg := range os.Args {
if unsafeShell.MatchString(arg) {
safe = false
break
}
if slices.ContainsFunc(os.Args, unsafeShell.MatchString) {
safe = false
}
if safe {
i := len(os.Args) - flag.NArg()
@@ -316,7 +313,7 @@ func passphrasePromptForEncryption() (string, error) {
p := string(pass)
if p == "" {
var words []string
for i := 0; i < 10; i++ {
for range 10 {
words = append(words, randomWord())
}
p = strings.Join(words, "-")

View File

@@ -30,17 +30,17 @@ import (
// l is a logger with no prefixes.
var l = log.New(os.Stderr, "", 0)
func printf(format string, v ...interface{}) {
func printf(format string, v ...any) {
l.Printf("age: "+format, v...)
}
func errorf(format string, v ...interface{}) {
func errorf(format string, v ...any) {
l.Printf("age: error: "+format, v...)
l.Printf("age: report unexpected or unhelpful errors at https://filippo.io/age/report")
os.Exit(1)
}
func warningf(format string, v ...interface{}) {
func warningf(format string, v ...any) {
l.Printf("age: warning: "+format, v...)
}
@@ -53,7 +53,7 @@ func errorWithHint(error string, hints ...string) {
os.Exit(1)
}
func printfToTerminal(format string, v ...interface{}) error {
func printfToTerminal(format string, v ...any) error {
return term.WithTerminal(func(_, out *os.File) error {
_, err := fmt.Fprintf(out, "age: "+format+"\n", v...)
return err

View File

@@ -138,7 +138,7 @@ func convert(in io.Reader, out io.Writer) {
}
}
func errorf(format string, v ...interface{}) {
func errorf(format string, v ...any) {
log.Printf("age-plugin-pq: error: "+format, v...)
log.Fatalf("age-plugin-pq: report unexpected or unhelpful errors at https://filippo.io/age/report")
}

View File

@@ -37,7 +37,7 @@ func polymod(values []byte) uint32 {
top := chk >> 25
chk = (chk & 0x1ffffff) << 5
chk = chk ^ uint32(v)
for i := 0; i < 5; i++ {
for i := range 5 {
bit := top >> i & 1
if bit == 1 {
chk ^= generator[i]

View File

@@ -77,10 +77,7 @@ func (w *WrappedBase64Encoder) writeWrapped(p []byte) (int, error) {
panic("age: internal error: non-empty WrappedBase64Encoder.buf")
}
for len(p) > 0 {
toWrite := ColumnsPerLine - (w.written % ColumnsPerLine)
if toWrite > len(p) {
toWrite = len(p)
}
toWrite := min(ColumnsPerLine-(w.written%ColumnsPerLine), len(p))
n, _ := w.buf.Write(p[:toWrite])
w.written += n
p = p[n:]
@@ -228,7 +225,7 @@ func (e *ParseError) Unwrap() error {
return e.err
}
func errorf(format string, a ...interface{}) error {
func errorf(format string, a ...any) error {
return &ParseError{fmt.Errorf(format, a...)}
}

View File

@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build go1.18
// +build go1.18
package format_test

View File

@@ -566,13 +566,13 @@ func (p *Plugin) Confirm(prompt, yes, no string) (choseYes bool, err error) {
// fatalInteractf prints the error to stderr and sets the broken flag, so the
// Wrap/Unwrap caller can exit with an error.
func (p *Plugin) fatalInteractf(format string, args ...interface{}) error {
func (p *Plugin) fatalInteractf(format string, args ...any) error {
p.broken = true
fmt.Fprintf(p.stderr, format, args...)
return fmt.Errorf(format, args...)
}
func (p *Plugin) fatalf(format string, args ...interface{}) int {
func (p *Plugin) fatalf(format string, args ...any) int {
fmt.Fprintf(p.stderr, format, args...)
return 1
}

View File

@@ -13,7 +13,7 @@ import (
// The terminal is reached directly through /dev/tty or CONIN$/CONOUT$,
// bypassing standard input and output, so this UI can be used even when
// standard input or output are redirected.
func NewTerminalUI(printf, warningf func(format string, v ...interface{})) *ClientUI {
func NewTerminalUI(printf, warningf func(format string, v ...any)) *ClientUI {
return &ClientUI{
DisplayMessage: func(name, message string) error {
printf("%s plugin: %s", name, message)

View File

@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build go1.18
// +build go1.18
package age_test