| 1 | // Copyright 2024 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // This file contains tests of the printf checker's handling of non-constant |
| 6 | // format strings (golang/go#60529). |
| 7 | |
| 8 | package nonconst |
| 9 | |
| 10 | import ( |
| 11 | "fmt" |
| 12 | "log" |
| 13 | "os" |
| 14 | ) |
| 15 | |
| 16 | // As the language version is empty here, and the new check is gated on go1.24, |
| 17 | // diagnostics are suppressed here. |
| 18 | func nonConstantFormat(s string) { |
| 19 | fmt.Printf(s) |
| 20 | fmt.Printf(s, "arg") |
| 21 | fmt.Fprintf(os.Stderr, s) |
| 22 | log.Printf(s) |
| 23 | } |