Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
6daeb8a0
Commit
6daeb8a0
authored
Sep 26, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the github.com/skratchdot/open-golang/open package as a dependency.
parent
b3292e94
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
197 additions
and
0 deletions
+197
-0
Godeps.json
Godeps/Godeps.json
+4
-0
LICENSE-MIT
Godeps/_workspace/src/github.com/skratchdot/LICENSE-MIT
+22
-0
exec.go
...kspace/src/github.com/skratchdot/open-golang/open/exec.go
+15
-0
exec_darwin.go
...src/github.com/skratchdot/open-golang/open/exec_darwin.go
+15
-0
exec_windows.go
...rc/github.com/skratchdot/open-golang/open/exec_windows.go
+21
-0
open.go
...kspace/src/github.com/skratchdot/open-golang/open/open.go
+50
-0
open_test.go
...e/src/github.com/skratchdot/open-golang/open/open_test.go
+70
-0
No files found.
Godeps/Godeps.json
View file @
6daeb8a0
...
@@ -90,6 +90,10 @@
...
@@ -90,6 +90,10 @@
"Rev"
:
"9cad7da945e699385c1a3e115aa255211921c9bb"
"Rev"
:
"9cad7da945e699385c1a3e115aa255211921c9bb"
},
},
{
{
"ImportPath"
:
"github.com/skratchdot/open-golang/open"
,
"Rev"
:
"ba570a111973b539baf23c918213059543b5bb6e"
},
{
"ImportPath"
:
"github.com/stretchr/objx"
,
"ImportPath"
:
"github.com/stretchr/objx"
,
"Rev"
:
"d40df0cc104c06eae2dfe03d7dddb83802d52f9a"
"Rev"
:
"d40df0cc104c06eae2dfe03d7dddb83802d52f9a"
},
},
...
...
Godeps/_workspace/src/github.com/skratchdot/LICENSE-MIT
0 → 100644
View file @
6daeb8a0
Copyright (c) 2013 skratchdot
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Godeps/_workspace/src/github.com/skratchdot/open-golang/open/exec.go
0 → 100644
View file @
6daeb8a0
// +build !windows,!darwin
package
open
import
(
"os/exec"
)
func
open
(
input
string
)
*
exec
.
Cmd
{
return
exec
.
Command
(
"xdg-open"
,
input
)
}
func
openWith
(
input
string
,
appName
string
)
*
exec
.
Cmd
{
return
exec
.
Command
(
appName
,
input
)
}
Godeps/_workspace/src/github.com/skratchdot/open-golang/open/exec_darwin.go
0 → 100644
View file @
6daeb8a0
// +build darwin
package
open
import
(
"os/exec"
)
func
open
(
input
string
)
*
exec
.
Cmd
{
return
exec
.
Command
(
"open"
,
input
)
}
func
openWith
(
input
string
,
appName
string
)
*
exec
.
Cmd
{
return
exec
.
Command
(
"open"
,
"-a"
,
appName
,
input
)
}
Godeps/_workspace/src/github.com/skratchdot/open-golang/open/exec_windows.go
0 → 100644
View file @
6daeb8a0
// +build windows
package
open
import
(
"os/exec"
"strings"
)
func
cleaninput
(
input
string
)
string
{
r
:=
strings
.
NewReplacer
(
"&"
,
"^&"
)
return
r
.
Replace
(
input
)
}
func
open
(
input
string
)
*
exec
.
Cmd
{
return
exec
.
Command
(
"cmd"
,
"/C"
,
"start"
,
""
,
cleaninput
(
input
))
}
func
openWith
(
input
string
,
appName
string
)
*
exec
.
Cmd
{
return
exec
.
Command
(
"cmd"
,
"/C"
,
"start"
,
""
,
appName
,
cleaninput
(
input
))
}
Godeps/_workspace/src/github.com/skratchdot/open-golang/open/open.go
0 → 100644
View file @
6daeb8a0
/*
Open a file, directory, or URI using the OS's default
application for that object type. Optionally, you can
specify an application to use.
This is a proxy for the following commands:
OSX: "open"
Windows: "start"
Linux/Other: "xdg-open"
This is a golang port of the node.js module: https://github.com/pwnall/node-open
*/
package
open
/*
Open a file, directory, or URI using the OS's default
application for that object type. Wait for the open
command to complete.
*/
func
Run
(
input
string
)
error
{
return
open
(
input
)
.
Run
()
}
/*
Open a file, directory, or URI using the OS's default
application for that object type. Don't wait for the
open command to complete.
*/
func
Start
(
input
string
)
error
{
return
open
(
input
)
.
Start
()
}
/*
Open a file, directory, or URI using the specified application.
Wait for the open command to complete.
*/
func
RunWith
(
input
string
,
appName
string
)
error
{
return
openWith
(
input
,
appName
)
.
Run
()
}
/*
Open a file, directory, or URI using the specified application.
Don't wait for the open command to complete.
*/
func
StartWith
(
input
string
,
appName
string
)
error
{
return
openWith
(
input
,
appName
)
.
Start
()
}
Godeps/_workspace/src/github.com/skratchdot/open-golang/open/open_test.go
0 → 100644
View file @
6daeb8a0
package
open
import
"testing"
func
TestRun
(
t
*
testing
.
T
)
{
// shouldn't error
input
:=
"https://google.com/"
err
:=
Run
(
input
)
if
err
!=
nil
{
t
.
Errorf
(
"open.Run(
\"
%s
\"
) threw an error: %s"
,
input
,
err
)
}
// should error
input
=
"xxxxxxxxxxxxxxx"
err
=
Run
(
input
)
if
err
==
nil
{
t
.
Errorf
(
"Run(
\"
%s
\"
) did not throw an error as expected"
,
input
)
}
}
func
TestStart
(
t
*
testing
.
T
)
{
// shouldn't error
input
:=
"https://google.com/"
err
:=
Start
(
input
)
if
err
!=
nil
{
t
.
Errorf
(
"open.Start(
\"
%s
\"
) threw an error: %s"
,
input
,
err
)
}
// shouldn't error
input
=
"xxxxxxxxxxxxxxx"
err
=
Start
(
input
)
if
err
!=
nil
{
t
.
Errorf
(
"open.Start(
\"
%s
\"
) shouldn't even fail on invalid input: %s"
,
input
,
err
)
}
}
func
TestRunWith
(
t
*
testing
.
T
)
{
// shouldn't error
input
:=
"https://google.com/"
app
:=
"firefox"
err
:=
RunWith
(
input
,
app
)
if
err
!=
nil
{
t
.
Errorf
(
"open.RunWith(
\"
%s
\"
,
\"
%s
\"
) threw an error: %s"
,
input
,
app
,
err
)
}
// should error
app
=
"xxxxxxxxxxxxxxx"
err
=
RunWith
(
input
,
app
)
if
err
==
nil
{
t
.
Errorf
(
"RunWith(
\"
%s
\"
,
\"
%s
\"
) did not throw an error as expected"
,
input
,
app
)
}
}
func
TestStartWith
(
t
*
testing
.
T
)
{
// shouldn't error
input
:=
"https://google.com/"
app
:=
"firefox"
err
:=
StartWith
(
input
,
app
)
if
err
!=
nil
{
t
.
Errorf
(
"open.StartWith(
\"
%s
\"
,
\"
%s
\"
) threw an error: %s"
,
input
,
app
,
err
)
}
// shouldn't error
input
=
"[<Invalid URL>]"
err
=
StartWith
(
input
,
app
)
if
err
!=
nil
{
t
.
Errorf
(
"StartWith(
\"
%s
\"
,
\"
%s
\"
) shouldn't even fail on invalid input: %s"
,
input
,
app
,
err
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment