假设我有一个字符串" a-b-c-d",如果字符串由" - "分隔,我想替换" - " by":"否则我希望字符串保持不变。我怎么在Go中做到这一点?
package main
import (
"fmt"
"strings"
)
func main() {
data := "01-12-13-14-15-16"
// mac :="11:11:11:11:11:11"
// Split on comma.
result := strings.Split(data, "-")
result1 :=strings.Join(result,":")
// result11 := strings.Split(mac, "-")
//result12 :=strings.Join(mac,":")
fmt.Print(result1)
//fmt.Print(result12)
}