Skip to content

Instantly share code, notes, and snippets.

@trusch
Created April 26, 2018 09:45
Show Gist options
  • Save trusch/c6170f9ea3502de75c026b3e6a103e47 to your computer and use it in GitHub Desktop.
Save trusch/c6170f9ea3502de75c026b3e6a103e47 to your computer and use it in GitHub Desktop.
// -*- mode:go;mode:go-playground -*-
// snippet of code @ 2018-04-26 11:36:33
// === Go Playground ===
// Execute the snippet with Ctl-Return
// Remove the snippet completely with its dir and all files M-x `go-playground-rm`
package main
import (
"fmt"
"net/url"
"path/filepath"
)
func main() {
str := "foo.bar:5000"
uri, _ := url.Parse(str)
fmt.Println("without scheme: ", filepath.Join(uri.Host, "foobar"))
str = "http://foo.bar:5000"
uri, _ = url.Parse(str)
fmt.Println("with scheme: ", filepath.Join(uri.Host, "foobar"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment