本文整理汇总了Golang中github.com/skratchdot/open-golang/open.Start函数的典型用法代码示例。如果您正苦于以下问题:Golang Start函数的具体用法?Golang Start怎么用?Golang Start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Start函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
usr, err := user.Current()
if err != nil {
log.Fatal(err)
}
cache := filepath.Join(usr.HomeDir, ".ak", "news")
flag.Parse()
if flag.NArg() > 0 {
idx, e := strconv.ParseInt(flag.Arg(0), 0, 0)
if e != nil {
// not int
}
item := getItem(cache, idx)
if comment {
open.Start(fmt.Sprintf("%s%s%d", HACKERWEB, "/#/item/", item.ID))
} else {
open.Start(item.URL)
}
} else {
if next {
var news []Item
res, err := http.Get(NEWS2)
if err != nil {
log.Fatal(err)
}
bytes, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
res.Body.Close()
populateCache(cache, bytes)
contents := string(bytes)
err = json.NewDecoder(strings.NewReader(contents)).Decode(&news)
if err != nil {
log.Fatal(err)
}
showNewsList(news)
} else {
var news []Item
res, err := http.Get(NEWS)
if err != nil {
log.Fatal(err)
}
bytes, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
res.Body.Close()
populateCache(cache, bytes)
contents := string(bytes)
err = json.NewDecoder(strings.NewReader(contents)).Decode(&news)
showNewsList(news)
}
}
}
开发者ID:anykao,项目名称:p,代码行数:57,代码来源:hn.go
示例2: main
// Our programs starts executing here
func main() {
// We need exactly 2 parameters: the first one is the program name,
// the second one should be the photo we want to operate on
if len(os.Args) != 2 {
fmt.Println("Please give a single file name as an argument!")
os.Exit(1)
}
// Retrieve the photo file name from the arguments array
fileName := os.Args[1]
// Try to opern the given file, error out on failure
file, err := os.Open(fileName)
exitOnError(err, "Couldn't open file")
// Try to extract the EXIF data, error out on failure
exifData, err := exif.Decode(file)
exitOnError(err, "Couldn't find EXIF data")
// Try to find a GPS coordinates entry in the EXIF data structure.
// Error out on failure
lat, long, err := exifData.LatLong()
exitOnError(err, "Couldn't read GPS coordinates")
// Create the final URL by using the Google Maps URL template
url := fmt.Sprintf(googleMapsURLTemplate, lat, long)
// Try to start the default browser for the current OS.
// Show the computer URL on error, so that the user can still
// access it manually
err = open.Start(url)
exitOnError(err, fmt.Sprintf(
"Couldn't start the default browser, please visit %v manually", url))
}
开发者ID:valsinats42,项目名称:show-on-map,代码行数:35,代码来源:main.go
示例3: QR
func (g *Commands) QR(byId bool) error {
kvChan := g.urler(byId, g.opts.Sources)
address := DefaultQRShareServer
if g.opts.Meta != nil {
meta := *(g.opts.Meta)
if retrAddress, ok := meta[AddressKey]; ok && len(retrAddress) >= 1 {
address = retrAddress[0]
}
}
address = strings.TrimRight(address, "/")
if envKeySet.PublicKey == "" {
envKeySet.PublicKey = "5160897b3586461e83e7279c10352ac4"
}
if envKeySet.PrivateKey == "" {
envKeySet.PrivateKey = "5a3451dadab74f75b16f754c0a931949"
}
for kv := range kvChan {
switch kv.value.(type) {
case error:
g.log.LogErrf("%s: %s\n", kv.key, kv.value)
continue
}
fileURI, ok := kv.value.(string)
if !ok {
continue
}
curTime := time.Now()
pl := meddler.Payload{
URI: fileURI,
RequestTime: curTime.Unix(),
Payload: fmt.Sprintf("%v%v", rand.Float64(), curTime),
PublicKey: envKeySet.PublicKey,
ExpiryTime: curTime.Add(time.Hour).Unix(),
}
plainTextToSign := pl.RawTextForSigning()
pl.Signature = fmt.Sprintf("%s", envKeySet.Sign([]byte(plainTextToSign)))
uv := pl.ToUrlValues()
encodedValues := uv.Encode()
fullUrl := fmt.Sprintf("%s/qr?%s", address, encodedValues)
if g.opts.Verbose {
g.log.Logf("%q => %q\n", kv.key, fullUrl)
}
if err := open.Start(fullUrl); err != nil {
g.log.Logf("qr: err %v %q\n", err, fullUrl)
}
}
return nil
}
开发者ID:YuhsiangLu,项目名称:drive,代码行数:60,代码来源:qr-share.go
示例4: showQRImage
func showQRImage(uuid string) (err error) {
qrUrl := `https://login.weixin.qq.com/qrcode/` + uuid
params := url.Values{}
params.Set("t", "webwx")
params.Set("_", strconv.FormatInt(time.Now().Unix(), 10))
req, err := http.NewRequest("POST", qrUrl, strings.NewReader(params.Encode()))
if err != nil {
return
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Cache-Control", "no-cache")
resp, err := Client.Do(req)
if err != nil {
return
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if err = createFile(QRImagePath, data, false); err != nil {
return
}
return open.Start(QRImagePath)
}
开发者ID:pathletboy,项目名称:wechat-deleted-friends-1,代码行数:30,代码来源:login.go
示例5: Open
func (g *Commands) Open(ot OpenType) error {
byId := (ot & IdOpen) != 0
kvChan := g.urler(byId)
for kv := range kvChan {
switch kv.value.(type) {
case error:
g.log.LogErrf("%s: %s\n", kv.key, kv.value)
continue
}
openArgs := []string{}
canAddUrl := (ot & BrowserOpen) != 0
if byId {
canAddUrl = true
} else if (ot & FileManagerOpen) != 0 {
openArgs = append(openArgs, g.context.AbsPathOf(kv.key))
}
if canAddUrl {
if castKey, ok := kv.value.(string); ok {
openArgs = append(openArgs, castKey)
}
}
for _, arg := range openArgs {
open.Start(arg)
}
}
return nil
}
开发者ID:hatchling,项目名称:drive,代码行数:33,代码来源:open.go
示例6: run
func run(dir, port, host string) {
open.Start(host)
fmt.Println("-> Listening on ", host)
fmt.Println("-> Press ctrl-c to kill process")
http.CloseIdleConnections()
log.Fatal(http.ListenAndServe(port, http.FileServer(http.Dir(dir))))
}
开发者ID:blurdsss,项目名称:speakeasy,代码行数:7,代码来源:speakeasy.go
示例7: setupSysTrayReal
func setupSysTrayReal() {
systray.SetIcon(icon.Data)
mUrl := systray.AddMenuItem("Go to Arduino Create (staging)", "Arduino Create")
mDebug := systray.AddMenuItem("Open debug console", "Debug console")
menuVer := systray.AddMenuItem("Agent version "+version+"-"+git_revision, "")
mPause := systray.AddMenuItem("Pause Plugin", "")
//mQuit := systray.AddMenuItem("Quit Plugin", "")
menuVer.Disable()
go func() {
<-mPause.ClickedCh
ports, _ := serial.GetPortsList()
for _, element := range ports {
spClose(element)
}
systray.Quit()
*hibernate = true
log.Println("Restart becayse setup went wrong?")
restart("")
}()
// go func() {
// <-mQuit.ClickedCh
// systray.Quit()
// exit()
// }()
go func() {
for {
<-mDebug.ClickedCh
logAction("log on")
open.Start("http://localhost" + port)
}
}()
// We can manipulate the systray in other goroutines
go func() {
for {
<-mUrl.ClickedCh
open.Start("http://create-staging.arduino.cc")
}
}()
}
开发者ID:brunodisilva,项目名称:arduino-create-agent,代码行数:45,代码来源:trayicon.go
示例8: main
func main() {
nc, _ := nats.Connect("nats://yourhost:4222")
defer nc.Close()
nc.QueueSubscribe(TOPIC, QUEUE, func(m *nats.Msg) {
fmt.Println(string(m.Data))
open.Start(string(m.Data))
})
select {}
}
开发者ID:anykao,项目名称:p,代码行数:9,代码来源:bopen.go
示例9: main
func main() {
flag.Parse()
url := template.URLQueryEscaper(flag.Args())
url = fmt.Sprintf("http://52.68.184.19:8080/search/%s", url)
fmt.Printf("open %s\n", url)
open.Start(url)
}
开发者ID:anykao,项目名称:p,代码行数:12,代码来源:main.go
示例10: webui
func webui() {
goji.Get("/", index)
goji.Get("/result/diff.txt", generateResult)
goji.Post("/diff", PostDiff)
//Fully backwards compatible with net/http's Handlers
//goji.Get("/result", http.RedirectHandler("/", 301))
if os.Getenv("DEBUG") == "" {
time.AfterFunc(500*time.Millisecond, func() {
open.Start("http://localhost:8000")
})
}
goji.Serve()
}
开发者ID:anykao,项目名称:p,代码行数:13,代码来源:diffjar.go
示例11: docPlugin
func docPlugin(c *cli.Context) {
if len(c.Args()) != 1 {
fmt.Printf("Which documentation do you want to open? Try 'apiplexy plugin-doc <plugin-name>'.\n")
os.Exit(1)
}
plugin, ok := apiplexy.AvailablePlugins()[c.Args()[0]]
if !ok {
fmt.Printf("Plugin '%s' not found. Try 'apiplexy plugins' to list available ones.\n", c.Args()[0])
os.Exit(1)
}
fmt.Printf("Opening documentation for '%s' at: %s\n", plugin.Name, plugin.Link)
open.Start(plugin.Link)
}
开发者ID:12foo,项目名称:apiplexy,代码行数:13,代码来源:apiplexy.go
示例12: doOpen
func doOpen(flags *flag.FlagSet) {
args := flags.Args()
branch, err := getBranchFromArgs(args)
checkError(err)
remote, err := git.GetRemoteURL("origin")
checkError(err)
cr, err := circle.GetTree(remote.Path, remote.RepoName, branch)
checkError(err)
if len(*cr) == 0 {
fmt.Printf("No results, are you sure there are tests for %s/%s?\n",
remote.Path, remote.RepoName)
return
}
latestBuild := (*cr)[0]
open.Start(latestBuild.BuildURL)
}
开发者ID:Shyp,项目名称:go-circle,代码行数:16,代码来源:main.go
示例13: main
func main() {
title := flag.String("title", "", "Optional Title")
script := flag.String("script", "", "lua script to filter/enrich data")
laddr := flag.String("addr", "", "Address on which to serve up the map")
flag.Usage = func() {
fmt.Fprintln(os.Stderr, usage)
flag.PrintDefaults()
}
flag.Parse()
if *script != "" {
if _, err := os.Stat(*script); os.IsNotExist(err) {
log.Fatal(err)
}
}
http.HandleFunc("/gidata", handleGIData)
http.Handle("/resources/", http.FileServer(rice.MustFindBox("public").HTTPBox()))
http.HandleFunc("/", serveIndex(*title))
/* Get the address from the command line or the environment */
address := *laddr
if "" == address {
address = os.Getenv("GIM_ADDR")
}
/* Failing that, use an ephemeral port on loopback */
if "" == address {
address = "127.0.0.1:0"
}
/* If it's a single port, prepend a localhost */
if _, err := strconv.Atoi(address); nil == err {
address = "127.0.0.1:" + address
}
go readStdin(*script)
l, err := net.Listen("tcp", address)
if err != nil {
log.Fatal(err)
}
go func() {
addr := fmt.Sprintf("http://%s", l.Addr())
log.Printf("Listening on %v\n", addr)
open.Start(addr)
}()
log.Fatal(http.Serve(l, nil))
}
开发者ID:kelixin,项目名称:geoipmap,代码行数:47,代码来源:main.go
示例14: execCmd
func execCmd(c *cli.Context) {
if len(c.Args()) < 1 {
fmt.Println("Specify Markdown file")
return
}
/* open webbrowser */
open.Start("http://0.0.0.0:8089")
ch := make(chan string)
gChan = make(chan string)
targetFileName = c.Args()[0]
go fileWatcher(ch)
/* for static files */
staticFilePath := path.Join(os.Getenv("GOPATH"), "src/github.com/hhatto/ftcat/static")
fs := http.FileServer(http.Dir(staticFilePath))
http.Handle("/static/", http.StripPrefix("/static/", fs))
/* index */
http.HandleFunc("/", indexHandler)
/* server sent events */
es := eventsource.New(nil, nil)
defer es.Close()
http.Handle("/events", es)
/* message broker */
go func() {
id := 1
for {
select {
case n := <-ch:
es.SendEventMessage(n, "cre", strconv.Itoa(id))
id++
case n := <-gChan:
es.SendEventMessage(n, "cre", strconv.Itoa(id))
id++
}
}
}()
log.Fatal(http.ListenAndServe(":8089", nil))
}
开发者ID:hhatto,项目名称:ftcat,代码行数:45,代码来源:main.go
示例15: DoOpen
func DoOpen(c *cli.Context) {
useOptions(c)
dest := c.Args().First()
log.Debugf("Open destination: %s", dest)
url := ""
message := ""
switch dest {
default:
fallthrough
case "deployed":
app, err := account.GetCurrentApp()
if err != nil {
message = "Sorry, could not find a deployed app to open."
}
url = "http://" + app.HostingSubdomain + ".appstax.io"
break
case "admin":
url = "http://appstax.com/admin/#/dashboard"
break
case "local":
url = "http://localhost:9000/"
break
}
if url != "" {
term.Printf("Opening %s in your browser.\n", url)
err := open.Start(url)
if err != nil {
message = "Ooops! Something went wrong."
}
}
if message != "" {
term.Section()
term.Println(message)
}
}
开发者ID:rootwzrd,项目名称:appstax-cli,代码行数:41,代码来源:open.go
示例16: openBrowser
func openBrowser() {
url := "http://" + host + "/tour.html"
tries := 0
for {
if tries > 100 {
fmt.Println("giving up after ", time.Duration(tries)*100*time.Microsecond)
os.Exit(1)
}
<-time.After(10 * time.Microsecond)
if _, err := http.Get(url); err == nil {
println("Opening " + url)
fmt.Println(open.Start(url))
return
}
tries++
}
}
开发者ID:manveru,项目名称:gotour,代码行数:21,代码来源:main.go
示例17: Auth
// Auth user against selected provider and return AccessToken
func Auth(provider string) AccessToken {
port := "7777"
go func() {
log.Infof("Starting HTTP server on 0.0.0.0:%s...", port)
http.HandleFunc("/oauth2", processOAuth)
http.HandleFunc("/store", persistToken)
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.WithField("error", err).Fatal("Unable to create listener")
}
}()
if provider == "bitbucket.org" {
log.Infof("Please authenticate yourself within [%s] provider in opened browser window ...", provider)
wg.Add(1)
open.Start("https://bitbucket.org/site/oauth2/authorize?client_id=FUGTa554rDNASAzdBg&response_type=token")
}
wg.Wait()
return accessToken
}
开发者ID:nildev,项目名称:tools,代码行数:22,代码来源:auth.go
示例18: OpenInBrowser
// OpenInBrowser stores the html under "<name><date>.html" in the current
// directory and opens it in the browser
func OpenInBrowser(name string, html string) error {
pwd, err := os.Getwd()
if err != nil {
fmt.Println(err)
}
fmt.Println("PWD", pwd)
//path := "file://" + pwd + "/" + "diff.html"
path := pwd + "/" + "diff-" + name + "_" + GetFormattedTimeShort(time.Now()) + ".html"
fmt.Println("PATH", path)
tmpFile, err := os.Create(path)
if err != nil {
return err
}
tmpFile.WriteString(html)
tmpFile.Close()
err = open.Start(path)
if err != nil {
log.Println(err)
}
return err
}
开发者ID:foomo,项目名称:shop,代码行数:25,代码来源:utils.go
示例19: main
func main() {
flag.StringVar(&presently.Dir, "d", "", "Directory of the repository")
flag.StringVar(&presently.Port, "p", "8080", "Port to listen")
flag.Parse()
var args = flag.Args()
if presently.Dir == "" {
if len(args) == 0 {
fmt.Println("You need to specify -dir")
flag.PrintDefaults()
os.Exit(0)
} else {
presently.Dir = args[0]
}
}
go func() {
url := "http://localhost:" + presently.Port
time.Sleep(400 * time.Millisecond)
open.Start(url)
}()
presently.Serve()
}
开发者ID:kenpu,项目名称:presently,代码行数:23,代码来源:dev.go
示例20: Open
func (b Bopen) Open(url string) {
open.Start(url)
}
开发者ID:anykao,项目名称:p,代码行数:3,代码来源:bopen_windows.go
注:本文中的github.com/skratchdot/open-golang/open.Start函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论