Install Open With
go get -u github.com/barandemirbas/open-with
Add to your imports to start using Open With
import "github.com/barandemirbas/open-with"
Browser function opens a new browser tab for pointing url with default browser.
openwith.Browser("https://github.com/barandemirbas/open-with")
openwith.Browser("127.0.0.1", 8000) // http://127.0.0.1:8000
openwith.Browser("127.0.0.1/path", 8000) // http://127.0.0.1:8000/path
Example with Browser function:
package main
import (
"github.com/barandemirbas/open-with"
"net/http"
)
type HttpHandler struct{}
func (h HttpHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
res.Write([]byte("Hello World!"))
}
func main() {
openwith.Browser("127.0.0.1", 8000)
http.ListenAndServe(":8000", HttpHandler{})
}