@kjk1/

book string replace

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9736019373561169","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"cGFja2FnZSBtYWluCgppbXBvcnQgKAoJImZtdCIKCSJzdHJpbmdzIgopCgpmdW5jIG1haW4oKSB7CgkvLyA6c2hvdyBzdGFydAoJcyA6PSAib3JpZ2luYWwgc3RyaW5nIG9yaWdpbmFsIgoJczIgOj0gc3RyaW5ncy5SZXBsYWNlKHMsICJvcmlnaW5hbCIsICJyZXBsYWNlZCIsIC0xKQoJZm10LlByaW50ZigiczI6ICclcydcbiIsIHMyKQoJLy8gOnNob3cgZW5kCn0K"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package main

import (
	"fmt"
	"strings"
)

func main() {
	// :show start
	s := "original string original"
	s2 := strings.Replace(s, "original", "replaced", -1)
	fmt.Printf("s2: '%s'\n", s2)
	// :show end
}