Merge pull request #27234 from hashicorp/alisdair/pkg-browser-override

command: Revert local patch for pkg/browser
This commit is contained in:
Alisdair McDiarmid 2020-12-10 10:27:15 -05:00 committed by GitHub
commit 94151ed5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 15 deletions

View File

@ -2,8 +2,6 @@ package webbrowser
import ( import (
"github.com/pkg/browser" "github.com/pkg/browser"
"os/exec"
"strings"
) )
// NewNativeLauncher creates and returns a Launcher that will attempt to interact // NewNativeLauncher creates and returns a Launcher that will attempt to interact
@ -15,18 +13,6 @@ func NewNativeLauncher() Launcher {
type nativeLauncher struct{} type nativeLauncher struct{}
func hasProgram(name string) bool {
_, err := exec.LookPath(name)
return err == nil
}
func (l nativeLauncher) OpenURL(url string) error { func (l nativeLauncher) OpenURL(url string) error {
// Windows Subsystem for Linux (bash for Windows) doesn't have xdg-open available
// but you can execute cmd.exe from there; try to identify it
if !hasProgram("xdg-open") && hasProgram("cmd.exe") {
r := strings.NewReplacer("&", "^&")
exec.Command("cmd.exe", "/c", "start", r.Replace(url)).Run()
}
return browser.OpenURL(url) return browser.OpenURL(url)
} }

2
go.mod
View File

@ -97,7 +97,7 @@ require (
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c // indirect github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c // indirect
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 github.com/pkg/browser v0.0.0-20201207095918-0426ae3fba23
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/posener/complete v1.2.1 github.com/posener/complete v1.2.1
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 // indirect github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 // indirect

2
go.sum
View File

@ -494,6 +494,8 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
github.com/pkg/browser v0.0.0-20201207095918-0426ae3fba23 h1:dofHuld+js7eKSemxqTVIo8yRlpRw+H1SdpzZxWruBc=
github.com/pkg/browser v0.0.0-20201207095918-0426ae3fba23/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=