Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick sample of Golang and Ruby for string manipulation
#The task is replacing the port number in the URL string
//in golang
import "fmt"
import "strings"
func main() {
url := "http://localhost:8080/foo/bar"
fmt.Println(strings.Replace(url, "8080", "8181", -1))
}
#in ruby
url = "http://localhost:8080/foo/bar"
puts url.gsub("8080", "8181")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment