Skip to content

Instantly share code, notes, and snippets.

@vbatts
Created March 4, 2019 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vbatts/3b9b68ba91c56eeefce98602a566a73c to your computer and use it in GitHub Desktop.
Save vbatts/3b9b68ba91c56eeefce98602a566a73c to your computer and use it in GitHub Desktop.
buffering features from go releases
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"))
}
// +build go1.12
package main
import "strings"
func ReplaceAll(n, old, new string) string {
return strings.ReplaceAll(n, old, new)
}
// +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