Skip to content

Commit 5715d73

Browse files
mrclmrRobert Griesemer
authored and
Robert Griesemer
committed
all: use strings.ReplaceAll where applicable
``` find . \ -not -path './.git/*' \ -not -path './test/*' \ -not -path './src/cmd/vendor/*' \ -not -wholename './src/strings/example_test.go' \ -type f \ -exec \ sed -i -E 's/strings\.Replace\((.+), -1\)/strings\.ReplaceAll\(\1\)/g' {} \; ``` Change-Id: I59e2e91b3654c41a32f17dd91ec56f250198f0d6 GitHub-Last-Rev: 0868b1e GitHub-Pull-Request: #73370 Reviewed-on: https://go-review.googlesource.com/c/go/+/665395 Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Keith Randall <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 2cb9e7f commit 5715d73

File tree

24 files changed

+54
-54
lines changed

24 files changed

+54
-54
lines changed

src/cmd/cgo/gcc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2863,7 +2863,7 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
28632863
if ss, ok := dwarfToName[s]; ok {
28642864
s = ss
28652865
}
2866-
s = strings.Replace(s, " ", "", -1)
2866+
s = strings.ReplaceAll(s, " ", "")
28672867
name := c.Ident("_Ctype_" + s)
28682868
tt := *t
28692869
typedef[name.Name] = &tt

src/cmd/cgo/internal/testplugin/plugin_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ func goCmd(t *testing.T, op string, args ...string) string {
145145

146146
// escape converts a string to something suitable for a shell command line.
147147
func escape(s string) string {
148-
s = strings.Replace(s, "\\", "\\\\", -1)
149-
s = strings.Replace(s, "'", "\\'", -1)
148+
s = strings.ReplaceAll(s, "\\", "\\\\")
149+
s = strings.ReplaceAll(s, "'", "\\'")
150150
// Conservative guess at characters that will force quoting
151151
if s == "" || strings.ContainsAny(s, "\\ ;#*&$~?!|[]()<>{}`") {
152152
s = "'" + s + "'"

src/cmd/cgo/out.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ func (p *Package) writeDefs() {
251251
}
252252

253253
if callsMalloc && !*gccgo {
254-
fmt.Fprint(fgo2, strings.Replace(cMallocDefGo, "PREFIX", cPrefix, -1))
255-
fmt.Fprint(fgcc, strings.Replace(strings.Replace(cMallocDefC, "PREFIX", cPrefix, -1), "PACKED", p.packedAttribute(), -1))
254+
fmt.Fprint(fgo2, strings.ReplaceAll(cMallocDefGo, "PREFIX", cPrefix))
255+
fmt.Fprint(fgcc, strings.ReplaceAll(strings.Replace(cMallocDefC, "PREFIX", cPrefix, -1), "PACKED", p.packedAttribute()))
256256
}
257257

258258
if err := fgcc.Close(); err != nil {
@@ -1954,7 +1954,7 @@ extern const char *_GoStringPtr(_GoString_ s);
19541954
`
19551955

19561956
func (p *Package) gccExportHeaderProlog() string {
1957-
return strings.Replace(gccExportHeaderProlog, "GOINTBITS", fmt.Sprint(8*p.IntSize), -1)
1957+
return strings.ReplaceAll(gccExportHeaderProlog, "GOINTBITS", fmt.Sprint(8*p.IntSize))
19581958
}
19591959

19601960
// gccExportHeaderProlog is written to the exported header, after the

src/cmd/compile/internal/dwarfgen/scope_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func TestScopeRanges(t *testing.T) {
226226
defer f.Close()
227227

228228
// the compiler uses forward slashes for paths even on windows
229-
src = strings.Replace(src, "\\", "/", -1)
229+
src = strings.ReplaceAll(src, "\\", "/")
230230

231231
pcln, err := f.PCLineTable()
232232
if err != nil {

src/cmd/compile/internal/logopt/log_opts.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ var mu = sync.Mutex{} // mu protects loggedOpts.
326326
// funcName is the name of the function
327327
// A typical use for this to accumulate an explanation for a missed optimization, for example, why did something escape?
328328
func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...interface{}) *LoggedOpt {
329-
pass = strings.Replace(pass, " ", "_", -1)
329+
pass = strings.ReplaceAll(pass, " ", "_")
330330
return &LoggedOpt{pos, lastPos, pass, funcName, what, args}
331331
}
332332

@@ -405,7 +405,7 @@ func fixSlash(f string) string {
405405
if os.PathSeparator == '/' {
406406
return f
407407
}
408-
return strings.Replace(f, string(os.PathSeparator), "/", -1)
408+
return strings.ReplaceAll(f, string(os.PathSeparator), "/")
409409
}
410410

411411
func uriIfy(f string) DocumentURI {

src/cmd/compile/internal/ssa/_gen/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func genOp() {
350350
if !needEffect {
351351
log.Fatalf("symEffect with aux %s not allowed", v.aux)
352352
}
353-
fmt.Fprintf(w, "symEffect: Sym%s,\n", strings.Replace(v.symEffect, ",", "|Sym", -1))
353+
fmt.Fprintf(w, "symEffect: Sym%s,\n", strings.ReplaceAll(v.symEffect, ",", "|Sym"))
354354
} else if needEffect {
355355
log.Fatalf("symEffect needed for aux %s", v.aux)
356356
}

src/cmd/compile/internal/ssa/_gen/rulegen.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1623,11 +1623,11 @@ func varCount1(loc, m string, cnt map[string]int) {
16231623
// normalizeWhitespace replaces 2+ whitespace sequences with a single space.
16241624
func normalizeWhitespace(x string) string {
16251625
x = strings.Join(strings.Fields(x), " ")
1626-
x = strings.Replace(x, "( ", "(", -1)
1627-
x = strings.Replace(x, " )", ")", -1)
1628-
x = strings.Replace(x, "[ ", "[", -1)
1629-
x = strings.Replace(x, " ]", "]", -1)
1630-
x = strings.Replace(x, ")=>", ") =>", -1)
1626+
x = strings.ReplaceAll(x, "( ", "(")
1627+
x = strings.ReplaceAll(x, " )", ")")
1628+
x = strings.ReplaceAll(x, "[ ", "[")
1629+
x = strings.ReplaceAll(x, " ]", "]")
1630+
x = strings.ReplaceAll(x, ")=>", ") =>")
16311631
return x
16321632
}
16331633

src/cmd/compile/internal/ssa/compile.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ func Compile(f *Func) {
169169
func (f *Func) DumpFileForPhase(phaseName string) io.WriteCloser {
170170
f.dumpFileSeq++
171171
fname := fmt.Sprintf("%s_%02d__%s.dump", f.Name, int(f.dumpFileSeq), phaseName)
172-
fname = strings.Replace(fname, " ", "_", -1)
173-
fname = strings.Replace(fname, "/", "_", -1)
174-
fname = strings.Replace(fname, ":", "_", -1)
172+
fname = strings.ReplaceAll(fname, " ", "_")
173+
fname = strings.ReplaceAll(fname, "/", "_")
174+
fname = strings.ReplaceAll(fname, ":", "_")
175175

176176
if ssaDir := os.Getenv("GOSSADIR"); ssaDir != "" {
177177
fname = filepath.Join(ssaDir, fname)
@@ -264,7 +264,7 @@ func PhaseOption(phase, flag string, val int, valString string) string {
264264
lastcr := 0
265265
phasenames := " check, all, build, intrinsics, genssa"
266266
for _, p := range passes {
267-
pn := strings.Replace(p.name, " ", "_", -1)
267+
pn := strings.ReplaceAll(p.name, " ", "_")
268268
if len(pn)+len(phasenames)-lastcr > 70 {
269269
phasenames += "\n "
270270
lastcr = len(phasenames)
@@ -400,7 +400,7 @@ commas. For example:
400400
return ""
401401
}
402402

403-
underphase := strings.Replace(phase, "_", " ", -1)
403+
underphase := strings.ReplaceAll(phase, "_", " ")
404404
var re *regexp.Regexp
405405
if phase[0] == '~' {
406406
r, ok := regexp.Compile(underphase[1:])

src/cmd/compile/internal/ssa/debug_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ func printVariableAndNormalize(v string, printer func(v string) string) string {
694694
if dollar == -1 { // some not entirely expected response, whine and carry on.
695695
if cr == -1 {
696696
response = strings.TrimSpace(response) // discards trailing newline
697-
response = strings.Replace(response, "\n", "<BR>", -1)
697+
response = strings.ReplaceAll(response, "\n", "<BR>")
698698
return "$ Malformed response " + response
699699
}
700700
response = strings.TrimSpace(response[:cr])
@@ -986,8 +986,8 @@ func asCommandLine(cwd string, cmd *exec.Cmd) string {
986986

987987
// escape inserts escapes appropriate for use in a shell command line
988988
func escape(s string) string {
989-
s = strings.Replace(s, "\\", "\\\\", -1)
990-
s = strings.Replace(s, "'", "\\'", -1)
989+
s = strings.ReplaceAll(s, "\\", "\\\\")
990+
s = strings.ReplaceAll(s, "'", "\\'")
991991
// Conservative guess at characters that will force quoting
992992
if strings.ContainsAny(s, "\\ ;#*&$~?!|[]()<>{}`") {
993993
s = " '" + s + "'"

src/cmd/compile/internal/ssa/func.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func (f *Func) LogStat(key string, args ...interface{}) {
342342
}
343343
n := "missing_pass"
344344
if f.pass != nil {
345-
n = strings.Replace(f.pass.name, " ", "_", -1)
345+
n = strings.ReplaceAll(f.pass.name, " ", "_")
346346
}
347347
f.Warnl(f.Entry.Pos, "\t%s\t%s%s\t%s", n, key, value, f.Name)
348348
}

src/cmd/compile/internal/ssa/html.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type HTMLWriter struct {
2929
}
3030

3131
func NewHTMLWriter(path string, f *Func, cfgMask string) *HTMLWriter {
32-
path = strings.Replace(path, "/", string(filepath.Separator), -1)
32+
path = strings.ReplaceAll(path, "/", string(filepath.Separator))
3333
out, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
3434
if err != nil {
3535
f.Fatalf("%v", err)
@@ -929,7 +929,7 @@ func (w *HTMLWriter) WriteMultiTitleColumn(phase string, titles []string, class,
929929
if w == nil {
930930
return
931931
}
932-
id := strings.Replace(phase, " ", "-", -1)
932+
id := strings.ReplaceAll(phase, " ", "-")
933933
// collapsed column
934934
w.Printf("<td id=\"%v-col\" class=\"collapsed\"><div>%v</div></td>", id, phase)
935935

@@ -1089,7 +1089,7 @@ func (d *dotWriter) writeFuncSVG(w io.Writer, phase string, f *Func) {
10891089
return
10901090
}
10911091
fmt.Fprint(pipe, `digraph "" { margin=0; ranksep=.2; `)
1092-
id := strings.Replace(phase, " ", "-", -1)
1092+
id := strings.ReplaceAll(phase, " ", "-")
10931093
fmt.Fprintf(pipe, `id="g_graph_%s";`, id)
10941094
fmt.Fprintf(pipe, `node [style=filled,fillcolor=white,fontsize=16,fontname="Menlo,Times,serif",margin="0.01,0.03"];`)
10951095
fmt.Fprintf(pipe, `edge [fontsize=16,fontname="Menlo,Times,serif"];`)
@@ -1270,7 +1270,7 @@ func newDotWriter(mask string) *dotWriter {
12701270
return nil
12711271
}
12721272
// User can specify phase name with _ instead of spaces.
1273-
mask = strings.Replace(mask, "_", " ", -1)
1273+
mask = strings.ReplaceAll(mask, "_", " ")
12741274
ph := make(map[string]bool)
12751275
ranges := strings.Split(mask, ",")
12761276
for _, r := range ranges {

src/cmd/compile/internal/ssa/op.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ func (r *regInfo) String() string {
7777
s += "INS:\n"
7878
for _, i := range r.inputs {
7979
mask := fmt.Sprintf("%64b", i.regs)
80-
mask = strings.Replace(mask, "0", ".", -1)
80+
mask = strings.ReplaceAll(mask, "0", ".")
8181
s += fmt.Sprintf("%2d |%s|\n", i.idx, mask)
8282
}
8383
s += "OUTS:\n"
8484
for _, i := range r.outputs {
8585
mask := fmt.Sprintf("%64b", i.regs)
86-
mask = strings.Replace(mask, "0", ".", -1)
86+
mask = strings.ReplaceAll(mask, "0", ".")
8787
s += fmt.Sprintf("%2d |%s|\n", i.idx, mask)
8888
}
8989
s += "CLOBBERS:\n"
9090
mask := fmt.Sprintf("%64b", r.clobbers)
91-
mask = strings.Replace(mask, "0", ".", -1)
91+
mask = strings.ReplaceAll(mask, "0", ".")
9292
s += fmt.Sprintf(" |%s|\n", mask)
9393
return s
9494
}

src/cmd/compile/internal/test/testdata/flowgraph_generator1.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var labels string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
9999
func blocks(spec string) (blocks []string, fnameBase string) {
100100
spec = strings.ToUpper(spec)
101101
blocks = strings.Split(spec, ",")
102-
fnameBase = strings.Replace(spec, ",", "_", -1)
102+
fnameBase = strings.ReplaceAll(spec, ",", "_")
103103
return
104104
}
105105

src/cmd/compile/internal/test/testdata/gen/arithConstGen.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func {{.Name}}_{{.FNumber}}_{{.Type_}}(a {{.Type_}}) {{.Type_}} { return {{.Numb
175175
if len(s.u) > 0 {
176176
for _, i := range s.u {
177177
fd.Number = fmt.Sprintf("%d", i)
178-
fd.FNumber = strings.Replace(fd.Number, "-", "Neg", -1)
178+
fd.FNumber = strings.ReplaceAll(fd.Number, "-", "Neg")
179179

180180
// avoid division by zero
181181
if o.name != "mod" && o.name != "div" || i != 0 {
@@ -201,7 +201,7 @@ func {{.Name}}_{{.FNumber}}_{{.Type_}}(a {{.Type_}}) {{.Type_}} { return {{.Numb
201201
}
202202
for _, i := range s.i {
203203
fd.Number = fmt.Sprintf("%d", i)
204-
fd.FNumber = strings.Replace(fd.Number, "-", "Neg", -1)
204+
fd.FNumber = strings.ReplaceAll(fd.Number, "-", "Neg")
205205

206206
// avoid division by zero
207207
if o.name != "mod" && o.name != "div" || i != 0 {
@@ -242,7 +242,7 @@ type test_%[1]s%[2]s struct {
242242
fd := cfncData{s.name, o.name, s.name, o.symbol, "", "", "", ""}
243243
for _, i := range s.u {
244244
fd.Number = fmt.Sprintf("%d", i)
245-
fd.FNumber = strings.Replace(fd.Number, "-", "Neg", -1)
245+
fd.FNumber = strings.ReplaceAll(fd.Number, "-", "Neg")
246246

247247
// unsigned
248248
for _, j := range s.u {
@@ -282,7 +282,7 @@ type test_%[1]s%[2]s struct {
282282
fd := cfncData{s.name, o.name, s.name, o.symbol, "", "", "", ""}
283283
for _, i := range s.i {
284284
fd.Number = fmt.Sprintf("%d", i)
285-
fd.FNumber = strings.Replace(fd.Number, "-", "Neg", -1)
285+
fd.FNumber = strings.ReplaceAll(fd.Number, "-", "Neg")
286286
for _, j := range s.i {
287287
if o.name != "mod" && o.name != "div" || j != 0 {
288288
fd.Ans = ansS(i, j, s.name, o.symbol)

src/cmd/compile/internal/types2/assignments.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func (check *Checker) typesSummary(list []Type, variadic, hasDots bool) string {
318318
} else {
319319
// If we don't have a number, omit the "untyped" qualifier
320320
// for compactness.
321-
s = strings.Replace(t.(*Basic).name, "untyped ", "", -1)
321+
s = strings.ReplaceAll(t.(*Basic).name, "untyped ", "")
322322
}
323323
default:
324324
s = check.sprintf("%s", t)

src/cmd/dist/build.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ func banner() {
19231923

19241924
if gohostos == "plan9" {
19251925
// Check that GOROOT/bin is bound before /bin.
1926-
pid := strings.Replace(readfile("#c/pid"), " ", "", -1)
1926+
pid := strings.ReplaceAll(readfile("#c/pid"), " ", "")
19271927
ns := fmt.Sprintf("/proc/%s/ns", pid)
19281928
if !strings.Contains(readfile(ns), fmt.Sprintf("bind -b %s /bin", gorootBin)) {
19291929
xprintf("*** You need to bind %s before /bin.\n", gorootBin)

src/cmd/internal/objabi/flag.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func expandArgs(in []string) (out []string) {
6161
if err != nil {
6262
log.Fatal(err)
6363
}
64-
args := strings.Split(strings.TrimSpace(strings.Replace(string(slurp), "\r", "", -1)), "\n")
64+
args := strings.Split(strings.TrimSpace(strings.ReplaceAll(string(slurp), "\r", "")), "\n")
6565
for i, arg := range args {
6666
args[i] = DecodeArg(arg)
6767
}
@@ -299,7 +299,7 @@ func (f *DebugFlag) Set(debugstr string) error {
299299
nl := fmt.Sprintf("\n\t%-*s\t", maxLen, "")
300300
for _, name := range names {
301301
help := f.tab[name].help
302-
fmt.Printf("\t%-*s\t%s\n", maxLen, name, strings.Replace(help, "\n", nl, -1))
302+
fmt.Printf("\t%-*s\t%s\n", maxLen, name, strings.ReplaceAll(help, "\n", nl))
303303
}
304304
if f.debugSSA != nil {
305305
// ssa options have their own help

src/cmd/internal/testdir/testdir_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func linkFile(runcmd runCmd, goname string, importcfg string, ldflags []string)
237237
if importcfg == "" {
238238
importcfg = stdlibImportcfgFile()
239239
}
240-
pfile := strings.Replace(goname, ".go", ".o", -1)
240+
pfile := strings.ReplaceAll(goname, ".go", ".o")
241241
cmd := []string{goTool, "tool", "link", "-w", "-o", "a.exe", "-importcfg=" + importcfg}
242242
if *linkshared {
243243
cmd = append(cmd, "-linkshared", "-installsuffix=dynlink")
@@ -295,7 +295,7 @@ func (t test) goFileName() string {
295295
}
296296

297297
func (t test) goDirName() string {
298-
return filepath.Join(t.dir, strings.Replace(t.goFile, ".go", ".dir", -1))
298+
return filepath.Join(t.dir, strings.ReplaceAll(t.goFile, ".go", ".dir"))
299299
}
300300

301301
// goDirFiles returns .go files in dir.
@@ -1145,7 +1145,7 @@ func (t test) checkExpectedOutput(gotBytes []byte) error {
11451145
} else if err != nil {
11461146
return err
11471147
}
1148-
got = strings.Replace(got, "\r\n", "\n", -1)
1148+
got = strings.ReplaceAll(got, "\r\n", "\n")
11491149
if got != string(b) {
11501150
if err == nil {
11511151
return fmt.Errorf("output does not match expected in %s. Instead saw\n%s", filename, got)
@@ -1300,12 +1300,12 @@ func (test) updateErrors(out, file string) {
13001300
if err != nil || line < 0 || line >= len(lines) {
13011301
continue
13021302
}
1303-
msg = strings.Replace(msg, file, base, -1) // normalize file mentions in error itself
1303+
msg = strings.ReplaceAll(msg, file, base) // normalize file mentions in error itself
13041304
msg = strings.TrimLeft(msg, " \t")
13051305
for _, r := range []string{`\`, `*`, `+`, `?`, `[`, `]`, `(`, `)`} {
1306-
msg = strings.Replace(msg, r, `\`+r, -1)
1306+
msg = strings.ReplaceAll(msg, r, `\`+r)
13071307
}
1308-
msg = strings.Replace(msg, `"`, `.`, -1)
1308+
msg = strings.ReplaceAll(msg, `"`, `.`)
13091309
msg = tmpRe.ReplaceAllLiteralString(msg, `autotmp_[0-9]+`)
13101310
if errors[line] == nil {
13111311
errors[line] = make(map[string]bool)

src/cmd/link/internal/ld/macho.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func machoadddynlib(lib string, linkmode LinkMode) {
545545
}
546546

547547
func machoshbits(ctxt *Link, mseg *MachoSeg, sect *sym.Section, segname string) {
548-
buf := "__" + strings.Replace(sect.Name[1:], ".", "_", -1)
548+
buf := "__" + strings.ReplaceAll(sect.Name[1:], ".", "_")
549549

550550
msect := newMachoSect(mseg, buf, segname)
551551

@@ -1039,7 +1039,7 @@ func machosymtab(ctxt *Link) {
10391039
symstr.AddUint8('_')
10401040

10411041
// replace "·" as ".", because DTrace cannot handle it.
1042-
name := strings.Replace(ldr.SymExtname(s), "·", ".", -1)
1042+
name := strings.ReplaceAll(ldr.SymExtname(s), "·", ".")
10431043

10441044
name = mangleABIName(ctxt, ldr, s, name)
10451045
symstr.Addstring(name)

src/cmd/link/internal/ld/symtab.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func putelfsym(ctxt *Link, x loader.Sym, typ elf.SymType, curbind elf.SymBind) {
155155
// match exactly. Tools like DTrace will have to wait for now.
156156
if !ctxt.DynlinkingGo() {
157157
// Rewrite · to . for ASCII-only tools like DTrace (sigh)
158-
sname = strings.Replace(sname, "·", ".", -1)
158+
sname = strings.ReplaceAll(sname, "·", ".")
159159
}
160160

161161
if ctxt.DynlinkingGo() && bind == elf.STB_GLOBAL && curbind == elf.STB_LOCAL && ldr.SymType(x).IsText() {

src/cmd/link/internal/loader/loader.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2745,7 +2745,7 @@ func (reporter *ErrorReporter) Errorf(s Sym, format string, args ...interface{})
27452745
if s != 0 && reporter.ldr.SymName(s) != "" {
27462746
// Note: Replace is needed here because symbol names might have % in them,
27472747
// due to the use of LinkString for names of instantiating types.
2748-
format = strings.Replace(reporter.ldr.SymName(s), "%", "%%", -1) + ": " + format
2748+
format = strings.ReplaceAll(reporter.ldr.SymName(s), "%", "%%") + ": " + format
27492749
} else {
27502750
format = fmt.Sprintf("sym %d: %s", s, format)
27512751
}

src/debug/dwarf/line.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ func splitDrive(path string) (drive, rest string) {
837837
}
838838
if len(path) > 3 && (path[0] == '\\' || path[0] == '/') && (path[1] == '\\' || path[1] == '/') {
839839
// Normalize the path so we can search for just \ below.
840-
npath := strings.Replace(path, "/", `\`, -1)
840+
npath := strings.ReplaceAll(path, "/", `\`)
841841
// Get the host part, which must be non-empty.
842842
slash1 := strings.IndexByte(npath[2:], '\\') + 2
843843
if slash1 > 2 {

src/debug/dwarf/line_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ func TestLineGCCWindows(t *testing.T) {
9494

9595
toWindows := func(lf *LineFile) *LineFile {
9696
lf2 := *lf
97-
lf2.Name = strings.Replace(lf2.Name, "/home/austin/go.dev/", "C:\\workdir\\go\\", -1)
98-
lf2.Name = strings.Replace(lf2.Name, "/", "\\", -1)
97+
lf2.Name = strings.ReplaceAll(lf2.Name, "/home/austin/go.dev/", "C:\\workdir\\go\\")
98+
lf2.Name = strings.ReplaceAll(lf2.Name, "/", "\\")
9999
return &lf2
100100
}
101101
file1C := toWindows(file1C)

src/go/types/assignments.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)