Created
June 17, 2015 01:39
-
-
Save patio11/fe0abc1c18d09149e6c9 to your computer and use it in GitHub Desktop.
Quick sample of Golang and Ruby for string manipulation
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
#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