本文整理汇总了Golang中github.com/toqueteos/webbrowser.Open函数的典型用法代码示例。如果您正苦于以下问题:Golang Open函数的具体用法?Golang Open怎么用?Golang Open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Download
func (f *FileManager) Download(request *messaging.FileRequest) messaging.FileResponse { // save the file to ftp and download via ftp on browser
fileResponse := messaging.FileResponse{}
if len(request.Body) == 0 {
} else {
var saveServerPath string = request.RootSavePath
var accessServerPath string = request.RootGetPath
fmt.Println(request.RootSavePath)
fmt.Println(request.RootGetPath)
file := FileData{}
json.Unmarshal(request.Body, &file)
temp := common.DecodeFromBase64(file.Body)
ioutil.WriteFile((saveServerPath + request.FilePath + file.FileName), []byte(temp), 0666)
err := webbrowser.Open(accessServerPath + request.FilePath + file.FileName)
if err != nil {
fileResponse.IsSuccess = false
fileResponse.Message = "Downloading Failed!" + err.Error()
} else {
fileResponse.IsSuccess = true
fileResponse.Message = "Downloading file successfully completed"
}
}
return fileResponse
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:30,代码来源:FileManager.go
示例2: StartWeb
func StartWeb(wg sync.WaitGroup) {
defer wg.Done()
cfg := config.Read()
listenUri := fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port)
mux := http.NewServeMux()
mux.HandleFunc("/creds/info", web.RawCredHandler)
mux.HandleFunc("/creds/info/", web.InfoCredHandler)
mux.HandleFunc("/creds", CredHandler)
mux.HandleFunc("/users/", UsersHandler)
mux.HandleFunc("/connect", ConnectHandler)
mux.HandleFunc("/ping", PingHandler)
mux.HandleFunc("/protocol-handler", ProtocolHandlerHandler)
static := http.FileServer(http.Dir(config.AssetDir("htdocs")))
mux.Handle("/", static)
server := &http.Server{
Addr: listenUri,
Handler: mux,
}
log.Println("Webservice will start on", listenUri)
if cfg.Application.OpenWebUIOnStart {
log.Println("Opening web browser…")
// TODO: Create proper welcome page
webbrowser.Open(fmt.Sprintf("%s", listenUri))
}
panic(server.ListenAndServe())
}
开发者ID:jphastings,项目名称:credence,代码行数:34,代码来源:server.go
示例3: Initialize
func Initialize(newAddressList *addresslist.SafeIPList,
newSandwichSettings *settings.Settings,
newShutdown func(fileindex.FileManifest)) {
addressList = newAddressList
sandwichSettings = newSandwichSettings
shutdown = newShutdown
go downloadThread()
go downloadThread()
go downloadThread()
go downloadThread()
DownloadQueue = make(chan *IPFilePair, 1000)
file, err := os.Open(util.ConfPath("manifest-cache.json"))
if err != nil && os.IsNotExist(err) {
fileManifest = client.BuildFileManifest()
} else if err != nil {
log.Println(err)
fileManifest = client.BuildFileManifest()
} else if xml, err := ioutil.ReadAll(file); err != nil {
log.Println(err)
fileManifest = client.BuildFileManifest()
file.Close()
} else if fileManifest, err = fileindex.UnmarshalManifest(xml); err != nil {
fileManifest = client.BuildFileManifest()
} else {
fileManifest = client.CleanManifest(fileManifest)
file.Close()
}
go InitializeFancyStuff()
if !sandwichSettings.DontOpenBrowserOnStart {
webbrowser.Open("http://localhost:" + sandwichSettings.LocalServerPort)
}
}
开发者ID:sandwich-share,项目名称:sandwich-go,代码行数:32,代码来源:front-end.go
示例4: openIssue
func openIssue(issue *github.Issue) error {
task := fmt.Sprintf("Open issue #%v in the browser", *issue.Number)
if err := webbrowser.Open(*issue.HTMLURL); err != nil {
return errs.NewError(task, err)
}
return nil
}
开发者ID:jkotrlik,项目名称:salsaflow,代码行数:7,代码来源:code_review_tool.go
示例5: ServeTestGin
func (jts *JobTypeServer) ServeTestGin( //--port int,
htmlFiles_l []string) error {
router := jts.mkGinEngine(htmlFiles_l)
server := httptest.NewServer(router)
defer server.Close()
url := server.URL
// port_s := ""
// if port > 0 && port < 65536 {
// port_s = fmt.Sprintf(":%d", port)
// }
// url := fmt.Sprintf("http://localhost%s/", port_s)
go func() {
time.Sleep(100 * time.Millisecond)
err := webbrowser.Open(url)
if err != nil {
log.Error("FAILED to open url in browser", "err", err)
}
}()
// server.Start()
time.Sleep(3 * time.Second)
return nil
// router := jts.mkGinEngine(htmlFiles_l)
// return router.Run(port_s) // listen and server on 0.0.0.0:8080
}
开发者ID:ContiGuy,项目名称:conti-gui,代码行数:27,代码来源:srvgin.go
示例6: main
func main() {
var home RefHandler
var search SearchHandler
var login LoginHandler
var logout LogoutHandler
var admin AdminViewHandler
var searchAdmin SearchAdminHandler
var edit EditHandler
var delete DeleteHandler
var new NewHandler
port := ":8080"
log.Println("Starting Web Server 127.0.0.1" + port)
go Exit()
webbrowser.Open("http://localhost" + port)
mux := mux.NewRouter()
mux.Handle("/", home).Name("home")
mux.Handle("/search", search)
mux.Handle("/login", login).Methods("POST")
mux.Handle("/logout", logout)
mux.Handle("/admin", admin)
mux.Handle("/admin/search", searchAdmin)
mux.Handle("/admin/new", new)
mux.Handle("/admin/edit/{id}", edit)
mux.Handle("/admin/delete/{id}", delete)
err := http.ListenAndServe(port, mux)
check(err)
}
开发者ID:kameleon83,项目名称:referentiel-go,代码行数:33,代码来源:annuaire.go
示例7: ServeGin
func ServeGin(port int, baseDir string, htmlFiles_l []string) error {
router := gin.Default()
router.GET("/", func(c *gin.Context) {
eh := errHandler_T{}
var index_b []byte
eh.safe(func() {
for _, fn := range htmlFiles_l {
index_b, eh.err = ioutil.ReadFile(fn)
if eh.err == nil {
var n int64
n, eh.err = io.Copy(c.Writer, bytes.NewBuffer(index_b))
log.Info("serving local file index.html", "file", fn, "size", n, "err", eh.err)
break
}
}
if len(index_b) == 0 {
eh.err = wui.WriteWuiHtml(c.Writer)
log.Info("serving builtin index.html", "err", eh.err)
}
})
eh.ifErr(func() { c.AbortWithError(http.StatusBadRequest, eh.err) })
})
router.POST("/jobs/:jobType", func(c *gin.Context) {
// time.Sleep(300 * time.Millisecond)
eh := errHandler_T{}
eh.handleJobPost(baseDir, c)
})
router.GET("/jobs/:jobType", func(c *gin.Context) {
// time.Sleep(300 * time.Millisecond)
eh := errHandler_T{}
eh.handleJobList(baseDir, c)
})
router.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
port_s := ""
if port > 0 && port < 65536 {
port_s = fmt.Sprintf(":%d", port)
}
url := fmt.Sprintf("http://localhost%s/", port_s)
go func() {
time.Sleep(100 * time.Millisecond)
err := webbrowser.Open(url)
if err != nil {
log.Error("FAILED to open url in browser", "err", err)
}
}()
return router.Run(port_s) // listen and server on 0.0.0.0:8080
}
开发者ID:ContiGuy,项目名称:conti-gui,代码行数:59,代码来源:srvVersions.go
示例8: browserOutput
// opens browser with Subreddits representation
func browserOutput(subreddits []*Subreddit, port string) {
viewHandler := func(w http.ResponseWriter, r *http.Request) {
page := `<html>
<head>
<style type="text/css">
body {margin: 0 auto; max-width: 640px; background: black; color: #CCC; font-family: Courier New, Courier; line-height: 1.2em;}
.content {padding: 10px;}
.entry {margin-bottom: 20px;}
.entry-title a:link, .entry-title a:visited {color: #9df; text-decoration: none;}
.entry-permalink a:link, .entry-permalink a:visited {color: #CCC; text-decoration: none; font-size: 0.8em;}
.entry a:hover {color: #6cf;}
.entry-image {width: 100%; margin-top: 10px;}
</style>
</head>
<body>
<div class="content">
{{ range . }}
<h1>{{ .Name }}</h1>
<div class="subreddit">
{{ range .Entries }}
<div class="entry">
<span class="entry-score">{{ .Score }}<span>
<span class="entry-title"><a target="_blank" href="{{ .URL }}">{{ .Title }}</a><span>
<span class="entry-permalink"><a target="_blank" href="http://www.reddit.com{{ .Permalink }}">comments</a><span>
{{ if .IsImage }}
<br /><img class="entry-image" src="{{ .URL }}" alt="" />
{{ end }}
{{ if .HasEmbed }}
<br />{{ .EmbedHtml }}
{{ end }}
</div>
{{ end }}
</div>
{{ end }}
</div>
</body>
</html>`
t := template.New("browser")
t, _ = t.Parse(page)
t.Execute(w, subreddits)
}
wait := make(chan bool)
http.HandleFunc("/", viewHandler)
log.Println("HTTP server starting, go to http://localhost:" + port)
go func() {
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Fatal("ListenAndServe: ", err)
}
wait <- true
}()
webbrowser.Open("http://localhost:" + port)
<-wait
}
开发者ID:sara62,项目名称:fire,代码行数:57,代码来源:fire.go
示例9: main
func main() {
noBrowser := false
flag.BoolVar(&noBrowser, "noBrowser", false, "If set, no browser is opened automatically.")
flag.Parse()
done := make(chan bool, 1)
go bowieweb.Serve(done)
// start web browser
if !noBrowser {
webbrowser.Open("http://localhost:8000")
}
// wait for bowieweb to finish serving
<-done
}
开发者ID:Schokomuesl1,项目名称:bowie,代码行数:14,代码来源:bowieMain.go
示例10: main
func main() {
anaconda.SetConsumerKey("j62kyFWBVqCiJElWSHvofSz59")
anaconda.SetConsumerSecret("FmA9RF7MAEwLbvXfvYRgZMMstinToo6kbR7CcwfpdhWrsEPyrg")
// webbrowser.Open()
url, cred, _ := anaconda.AuthorizationURL("")
webbrowser.Open(url)
var pincode int64
fmt.Scan(&pincode)
newcred, _, _ := anaconda.GetCredentials(cred, strconv.FormatInt(pincode, 10))
fmt.Printf("%v\n%v\n", newcred.Token, newcred.Secret)
}
开发者ID:KazushiSakashita,项目名称:MAOUVS,代码行数:14,代码来源:testn.go
示例11: main
func main() {
data, err := ioutil.ReadFile(*googleConfigJSON)
if err != nil {
log.Panic(err)
}
conf, err := Oauth2ConfigFromJSON(data)
if err != nil {
log.Panic(err)
}
// Redirect user to consent page to ask for permission
// for the scopes specified above.
url := conf.AuthCodeURL("state", oauth2.AccessTypeOffline)
fmt.Printf("Enter the code returned after authorising access: ")
webbrowser.Open(url)
// Use the authorization code that is pushed to the redirect URL.
// NewTransportWithCode will do the handshake to retrieve
// an access token and initiate a Transport that is
// authorized and authenticated by the retrieved token.
var code string
if _, err := fmt.Scan(&code); err != nil {
log.Panic(err)
}
tok, err := conf.Exchange(oauth2.NoContext, code)
if err != nil {
log.Panic(err)
}
ac := gads.AuthConfig{
OAuth2Config: conf,
OAuth2Token: tok,
Auth: gads.Auth{
CustomerId: "INSERT_YOUR_CLIENT_CUSTOMER_ID_HERE",
DeveloperToken: "INSERT_YOUR_DEVELOPER_TOKEN_HERE",
UserAgent: "tests (Golang 1.4 github.com/emiddleton/gads)",
},
}
configData, err := json.MarshalIndent(&ac, "", " ")
if err != nil {
log.Panic(err)
}
err = ioutil.WriteFile(*newConfigJSON, configData, 0600)
if err != nil {
log.Panic(err)
}
}
开发者ID:Nyarum,项目名称:gads,代码行数:47,代码来源:setup_oauth2.go
示例12: WaitForServer
func WaitForServer() {
log.Printf("Waiting for listener on port %d", *args.Port)
url := fmt.Sprintf("http://localhost:%d/edit/%s", *args.Port, url.QueryEscape(*args.File))
for {
time.Sleep(time.Millisecond * 50)
resp, err := http.Get(url)
if err != nil {
continue
}
resp.Body.Close()
break
}
log.Println("Opening " + url)
if err := webbrowser.Open(url); err != nil {
log.Printf("Possible error while opening browser: %s", err)
}
}
开发者ID:nochso,项目名称:gomd,代码行数:17,代码来源:gomd.go
示例13: main
func main() {
go func() {
fmt.Println("Création du .json le ", time.Now())
fmt.Println("Veuillez patienter quelques instants. Une fois fini, un message vous l'indiquera.")
createFile(filenameCsv)
if err := filepath.Walk(root, walkpath); err == nil {
if err := jsonWrite(filenameCsv); err == nil {
webbrowser.Open("http://localhost:8080")
}
}
}()
log.Println("Le serveur est bien démarré")
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("."))))
http.ListenAndServe(":8080", nil)
}
开发者ID:kameleon83,项目名称:searchWordsPagesStatic,代码行数:18,代码来源:generate-search.go
示例14: view
func view(cmd string, args []string) {
desc := "view listed pictures in browser-based gallery (or piped from stdin)"
fs := newFlagSet(cmd, "[PIC-ID...]", desc)
fs.BoolVar(&noedit, "noedit", false, "don't allow editing of anything in library")
fs.StringVar(&addr, "addr", "127.0.0.1:", "ip and port to serve gallery at")
fs.BoolVar(&all, "all", false, "true to view every file in the library")
fs.Parse(args)
l, err := net.Listen("tcp", addr)
check(err)
addr = l.Addr().String()
go runserve(l, fs.Args())
log.Printf("serving on address %v", addr)
err = webbrowser.Open(addr)
check(err)
select {}
}
开发者ID:rwcarlsen,项目名称:gallery,代码行数:19,代码来源:pics.go
示例15: main
func main() {
app := cli.NewApp()
app.Name = "go-pr"
app.Usage = "Create a Pull Request for the current branch"
app.UsageText = `
go-pr @target-branch # default target-user to your Github user
go-pr target-user/[email protected]
go-pr target-user/target-repo # default target-branch to master
go-pr target-user # default target-branch to master and target-repo to the name of your Github repo
`
app.Version = "0.0.1"
app.Author = "Bao Pham"
app.Email = "[email protected]"
app.Before = func(c *cli.Context) error {
if len(c.Args()) < 1 {
return errors.New("Target is required")
}
return nil
}
app.Action = func(c *cli.Context) {
remote := getRemote()
branch := getBranch()
currentRepo := NewRepo(remote, branch)
target := parseTarget(c.Args().First(), currentRepo)
if !currentRepo.IsGithub() {
println("Only support Github for now")
os.Exit(1)
}
webbrowser.Open(fmt.Sprintf("https://github.com/%s/%s/compare/%s...%s:%s",
target.username, target.name, target.branch,
currentRepo.username, currentRepo.branch))
}
app.Run(os.Args)
}
开发者ID:baopham,项目名称:go-pr,代码行数:43,代码来源:main.go
示例16: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
proxy := goproxy.NewProxyHttpServer()
proxy.OnResponse().DoFunc(proxyHandler)
go func() {
err := http.ListenAndServe(":8080", proxy)
if err != nil {
log.Fatal(err)
}
}()
go func() {
time.Sleep(time.Second * 1)
webbrowser.Open("http://localhost:8081/admin/cable-Systeminfo.asp")
}()
proxyUrl, _ := url.Parse("http://localhost:8080/")
httpClient = &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}}
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8081", nil))
}
开发者ID:habohitron,项目名称:habohitron,代码行数:20,代码来源:main.go
示例17: serve
func serve(cmd string, args []string) {
desc := "serve listed pics in a browser-based picture gallery (or piped from stdin)"
fs := newFlagSet(cmd, "[PIC-ID...]", desc)
fs.StringVar(&addr, "addr", "127.0.0.1:7777", "ip and port to serve gallery at")
view := fs.Bool("view", false, "opens browser window to gallery page")
fs.BoolVar(&noedit, "noedit", false, "don't allow editing of anything in library")
fs.BoolVar(&all, "all", false, "true to view every file in the library")
fs.Parse(args)
l, err := net.Listen("tcp", addr)
check(err)
go runserve(l, fs.Args())
log.Printf("serving on address %v", addr)
if *view {
err = webbrowser.Open(addr)
check(err)
}
select {}
}
开发者ID:rwcarlsen,项目名称:gallery,代码行数:21,代码来源:pics.go
示例18: Auth
func Auth(cKey string) (token string, err error) {
fmt.Println("Beginning authentication")
rToken, err := requestToken(cKey)
if err != nil {
return
}
url := fmt.Sprintf("https://getpocket.com/auth/authorize?request_token=%s&redirect_uri=%s", rToken, redirURI)
if err = webbrowser.Open(url); err == nil {
c := make(chan bool)
fmt.Println("Communicating with Pocket.")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Println("Got a response from Pocket.")
fmt.Fprint(w, "You can close this window now.")
c <- true
})
go func() {
if err := http.ListenAndServe(":50212", nil); err != nil {
panic(err)
}
}()
fmt.Println("Waiting for response.")
<-c
} else {
fmt.Println("Please open the following URL in your browser, log in and then press enter")
fmt.Println(url)
var str string
fmt.Scanf("%s", &str)
}
fmt.Println("Continuing authetication")
token, err = accessToken(cKey, rToken)
if err != nil {
return
}
return
}
开发者ID:sellweek,项目名称:pockettxt,代码行数:39,代码来源:auth.go
示例19: runServer
func runServer(l net.Listener, s *http.Server, openInBrowser bool) {
urls, err := netutil.ExpandHostedAddrToURLs(l.Addr(), url.URL{
Scheme: "http",
Path: "/",
})
if err != nil {
log.Printf("Could not resolve URL(s) for %s: %v", l.Addr(), err)
} else if len(urls) < 1 {
log.Printf("No URLs resolved for %s", l.Addr())
} else {
for i, u := range urls {
log.Printf("Web server URL #%d: %s", i, u.String())
}
if openInBrowser {
if err := webbrowser.Open(urls[0].String()); err != nil {
log.Printf("Could not open web browser: %v", err)
}
}
}
log.Printf("Web server started on %v", l.Addr())
err = s.Serve(l)
log.Printf("Web server stopped on %v with error: %v", l.Addr(), err)
}
开发者ID:huin,项目名称:artemis,代码行数:23,代码来源:service.go
示例20: ssoLogin
func ssoLogin() {
url := os.Getenv("SSO_URL")
if url == "" {
org := os.Getenv("HEROKU_ORGANIZATION")
for org == "" {
org = getString("Enter your organization name: ")
}
url = "https://sso.heroku.com/saml/" + org + "/init?cli=true"
}
Err("Opening browser for login...")
err := webbrowser.Open(url)
if err != nil {
Errln(" " + err.Error() + ".\nNavigate to " + cyan(url))
} else {
Errln(" done")
}
token := getPassword("Enter your access token (typing will be hidden): ")
user := getUserFromToken(token)
if user == "" {
ExitIfError(errors.New("Access token invalid."))
}
saveOauthToken(user, token)
Println("Logged in as " + cyan(user))
}
开发者ID:goldmane,项目名称:heroku-cli,代码行数:24,代码来源:login.go
注:本文中的github.com/toqueteos/webbrowser.Open函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论