Created
March 4, 2019 14:02
-
-
Save vbatts/3b9b68ba91c56eeefce98602a566a73c to your computer and use it in GitHub Desktop.
buffering features from go releases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
var str = "apples and bananas; apples and bananas; apples and bananas; apples and bananas;" | |
fmt.Println(ReplaceAll(str, "an", "op")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build go1.12 | |
package main | |
import "strings" | |
func ReplaceAll(n, old, new string) string { | |
return strings.ReplaceAll(n, old, new) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build !go1.12 | |
package main | |
import "strings" | |
func ReplaceAll(n, old, new string) string { | |
return strings.Replace(n, old, new, -1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment