当前位置: 首页>>代码示例>>Golang>>正文


Golang open.Run函数代码示例

本文整理汇总了Golang中github.com/skratchdot/open-golang/open.Run函数的典型用法代码示例。如果您正苦于以下问题:Golang Run函数的具体用法?Golang Run怎么用?Golang Run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: output

func (t *Terminal) output() bool {
	if t.printQuery {
		fmt.Println(string(t.input))
	}
	if len(t.expect) > 0 {
		fmt.Println(t.pressed)
	}
	found := len(t.selected) > 0
	if !found {
		cnt := t.merger.Length()
		if cnt > 0 && cnt > t.cy {
			desc := t.merger.Get(t.cy).AsString(t.ansi)
			pair := strings.Split(desc, " - ")
			err := open.Run(pair[1])
			if err != nil {
				println(err)
			}
			found = true
		}
	} else {
		sels := make([]selectedItem, 0, len(t.selected))
		for _, sel := range t.selected {
			sels = append(sels, sel)
		}
		sort.Sort(byTimeOrder(sels))
		for _, sel := range sels {
			open.Run(*sel.text)
			//fmt.Println(*sel.text)
		}
	}
	return found
}
开发者ID:jondot,项目名称:fzf,代码行数:32,代码来源:terminal.go

示例2: display

func display(plan string) {
	handler := func(w http.ResponseWriter, r *http.Request) {
		defer func() {
			if recover_string := recover(); recover_string != nil {
				error_handler(w, r, http.StatusNotFound)
			}
		}()
		var fileName string
		if r.URL.Path == "/" {
			fileName = "2048/index.html"
		} else {
			fileName = "2048/" + r.URL.Path[1:]
		}
		if _, err := os.Stat(fileName); err == nil {
			// File exists
			http.ServeFile(w, r, fileName)
		} else {
			panic(fmt.Sprintf("File not found %s", fileName))
		}

	}
	http.HandleFunc("/", handler)
	wg := &sync.WaitGroup{}
	wg.Add(1)
	go http.ListenAndServe("localhost:8080", nil)
	open.Run("http://localhost:8080")
	wg.Wait()
}
开发者ID:muhammedabuali,项目名称:AI2048,代码行数:28,代码来源:display.go

示例3: HelpCreateToken

func (l *Login) HelpCreateToken(e *Env) (string, error) {
	for i := 0; i < 4; i++ {
		fmt.Fprintf(e.Out, `
Input your account key or press ENTER to generate a new one.
NOTE: on pressing ENTER we'll try to open the url:
	%q
in default browser.
`,
			keysURL,
		)
		fmt.Fprintf(e.Out, `Account Key: `)

		var token string
		fmt.Fscanf(e.In, "%s\n", &token)
		token = strings.TrimSpace(token)
		if token != "" {
			return token, nil
		}

		err := open.Run(keysURL)
		if err != nil {
			fmt.Fprintf(e.Err,
				`Sorry, we couldn’t open the browser for you.
Go here to generate an account key: %q
`,
				keysURL,
			)
		}
	}
	return "", stackerr.New("Account key cannot be empty. Please try again.")
}
开发者ID:swhitley,项目名称:parse-cli,代码行数:31,代码来源:login.go

示例4: openExternalUrl

// openExternalUrl opens an external URL of one of our partners automatically
// at startup if configured to do so. It should only open the first time in
// a given session that Lantern is opened.
func openExternalUrl() {
	if openedExternal {
		log.Debugf("Not opening external URL again")
		return
	}
	defer func() {
		openedExternal = true
	}()

	path, s, err := packaged.ReadSettings()
	if err != nil {
		// Let packaged itself log errors as necessary.
		log.Debugf("Could not read yaml from %v: %v", path, err)
		return
	}

	var url string
	if s.StartupUrl == "" {
		return
	} else if strings.HasPrefix(s.StartupUrl, "https://www.facebook.com/manototv") {
		// Here we make sure to override any old manoto URLs with the latest.
		url = "https://www.facebook.com/manototv/app_128953167177144"
	} else {
		url = s.StartupUrl
	}
	time.Sleep(4 * time.Second)
	err = open.Run(url)
	if err != nil {
		log.Errorf("Error opening external page to `%v`: %v", uiaddr, err)
	}
}
开发者ID:kidaa,项目名称:lantern,代码行数:34,代码来源:ui.go

示例5: Show

// Show opens the UI in a browser. Note we know the UI server is
// *listening* at this point as long as Start is correctly called prior
// to this method. It may not be reading yet, but since we're the only
// ones reading from those incoming sockets the fact that reading starts
// asynchronously is not a problem.
func Show() {
	go func() {
		err := open.Run(uiaddr)
		if err != nil {
			log.Errorf("Error opening page to `%v`: %v", uiaddr, err)
		}
		if externalUrl != "NO"+"_URL" && !openedExternal {
			time.Sleep(4 * time.Second)
			err = open.Run(externalUrl)
			if err != nil {
				log.Errorf("Error opening external page to `%v`: %v", uiaddr, err)
			}
			openedExternal = true
		}
	}()
}
开发者ID:shizhh,项目名称:lantern,代码行数:21,代码来源:ui.go

示例6: getAccessToken

func getAccessToken(consumerKey, consumerSecret string) (a AccessToken, err error) {
	c := oauth.NewConsumer(
		consumerKey,
		consumerSecret,
		oauth.ServiceProvider{
			RequestTokenUrl:   "https://api.twitter.com/oauth/request_token",
			AuthorizeTokenUrl: "https://api.twitter.com/oauth/authorize",
			AccessTokenUrl:    "https://api.twitter.com/oauth/access_token",
		})

	requestToken, url, err := c.GetRequestTokenAndUrl("oob")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("(1) Go to: " + url)
	fmt.Println("(2) Grant access, you should get back a verification code.")
	open.Run(url)
	fmt.Print("(3) Enter that verification code here: ")

	verificationCode := ""
	fmt.Scanln(&verificationCode)

	authToken, err := c.AuthorizeToken(requestToken, verificationCode)
	if err != nil {
		log.Fatal(err)
	}
	a.Token = authToken.Token
	a.Secret = authToken.Secret

	err = saveAccessToken(a)

	return
}
开发者ID:upamune,项目名称:block,代码行数:34,代码来源:oauth.go

示例7: main

func main() {
	err := open.Run(DuckDuckGo + strings.Join(os.Args[1:], Sep))

	if err != nil {
		log.Panic(err)
	}
}
开发者ID:mcandre,项目名称:mcandre,代码行数:7,代码来源:main.go

示例8: readDropBoxAppConfig

func readDropBoxAppConfig(appName string) (*DropBoxAppConfig, error) {
	s := scan.CliScan{
		Scans: []scan.Scan{
			{Name: "token",
				Value: "",
				Usage: "please your dropbox accessToken",
				Env:   "",
			},
		},
	}

	ac := appConfig.NewDefaultAppConfig(appName)
	data, err := ac.ReadAppConfig()
	accessToken := string(data)
	if err != nil || accessToken == "" {

		// OAuth jump
		open.Run(accessTokenURL)

		// Scan accessToken
		accessToken = s.Scan("token")

		// config write
		if err := ac.WriteAppConfig([]byte(accessToken)); err != nil {
			return nil, err
		}
	}

	return &DropBoxAppConfig{*ac}, nil
}
开发者ID:kyokomi,项目名称:quick-image-cli,代码行数:30,代码来源:commands.go

示例9: main

func main() {
	flag.Parse()

	if flag.NArg() != 1 {
		print_usage(os.Args[0])
		os.Exit(1)
	}

	remotes, err := DetectRemote(flag.Arg(0))
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error())
		os.Exit(1)
	}

	for _, r := range remotes {
		url, err := MangleURL(r.Url)
		if err != nil {
			fmt.Fprintf(os.Stderr, "remote:%s, %s\n", r.Name, err.Error())
			continue
		}

		open.Run(url)
		break
	}
}
开发者ID:hatanakay,项目名称:gh-open,代码行数:25,代码来源:main.go

示例10: runServiceOpen

func (plugin OpenPlugin) runServiceOpen(cliConnection plugin.CliConnection, args []string) {
	output, err := cliConnection.CliCommandWithoutTerminalOutput("service", args[1], "--guid")
	if err != nil {
		fmt.Fprintln(os.Stdout, "error: service does not exist")
		os.Exit(1)
	}
	serviceInstanceGUID := strings.TrimSpace(output[0])

	output, err = cliConnection.CliCommandWithoutTerminalOutput("curl", fmt.Sprintf("/v2/service_instances/%s", serviceInstanceGUID))
	if err != nil {
		fmt.Fprintln(os.Stdout, "error: service does not exist")
		os.Exit(1)
	}
	jsonStr := ""
	for _, line := range output {
		jsonStr += line + "\n"
	}

	response := serviceInstanceResponse{}
	json.Unmarshal([]byte(jsonStr), &response)

	url := response.Entity.DashboardURL
	if url == "" {
		fmt.Println("No dashboard available")
	} else {
		open.Run(url)
	}
}
开发者ID:whitfiea,项目名称:cf-plugin-open,代码行数:28,代码来源:open.go

示例11: init

func init() {
	// Filters is the default set of global filters.
	revel.Filters = []revel.Filter{
		revel.PanicFilter,             // Recover from panics and display an error page instead.
		revel.RouterFilter,            // Use the routing table to select the right Action
		revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
		revel.ParamsFilter,            // Parse parameters into Controller.Params.
		revel.SessionFilter,           // Restore and write the session cookie.
		revel.FlashFilter,             // Restore and write the flash cookie.
		revel.ValidationFilter,        // Restore kept validation errors and save new ones from cookie.
		revel.I18nFilter,              // Resolve the requested language
		HeaderFilter,                  // Add some security based headers
		revel.InterceptorFilter,       // Run interceptors around the action.
		revel.CompressFilter,          // Compress the result.
		revel.ActionInvoker,           // Invoke the action.
	}

	// register startup functions with OnAppStart
	// ( order dependent )
	// revel.OnAppStart(InitDB)
	// revel.OnAppStart(FillCache)
	// Create a link back to node-webkit using the environment variable
	// populated by golang-nw's node-webkit code
	revel.OnAppStart(func() { open.Run("http://localhost:9000") })

}
开发者ID:browning,项目名称:gospider,代码行数:26,代码来源:init.go

示例12: main

func main() {
	var path string

	flag.Parse()

	if flag.NArg() != 1 {
		path = "./"
		// print_usage(os.Args[0])
		// os.Exit(1)
	} else {
		path = flag.Arg(0)
	}

	// remotes, err := DetectRemote(flag.Arg(0))
	remotes, err := DetectRemote(path)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error())
		os.Exit(1)
	}

	for _, r := range remotes {
		url, err := MangleURL(r.Url)
		if err != nil {
			fmt.Fprintf(os.Stderr, "remote:%s, %s\n", r.Name, err.Error())
			continue
		}

		open.Run(url)
		break
	}
}
开发者ID:theoden9014,项目名称:gh-open,代码行数:31,代码来源:main.go

示例13: main

func main() {
	input := bufio.NewScanner(os.Stdin)

	config := Config{}
	config_source, err := ioutil.ReadFile("config.json")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Can't read config.json: %v\n", err.Error())
		os.Exit(1)
	}
	if err := json.Unmarshal([]byte(config_source), &config); err != nil {
		fmt.Fprintf(os.Stderr, "Can't decode config.json: %v\n", err.Error())
		os.Exit(1)
	}

	if config.ClientId == "" {
		fmt.Fprintf(os.Stderr, "Invalid client_id in config.json\n")
		os.Exit(1)
	}

	open.Run(fmt.Sprintf("https://oauth.vk.com/authorize?client_id=%s&scope=audio"+
		"&redirect_uri=https://oauth.vk.com/blank.html&display=page&response_type=token", config.ClientId))
	fmt.Printf("Enter url from browser window:\n")
	input.Scan()
	oauthResponse := input.Text()
	if access_token, err := parseOauthResponse(oauthResponse); err == nil {
		downloadMusic(access_token)
	} else {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err.Error())
		os.Exit(1)
	}

}
开发者ID:Komly,项目名称:GoMusic,代码行数:32,代码来源:main.go

示例14: openInTatwebui

func (ui *tatui) openInTatwebui() {
	msg := ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position]
	base := strings.TrimSpace(viper.GetString("tatwebui-url"))

	if base == "" {
		ui.msg.Text = "You need to set TatWebui URL in your config file, see /set-tatwebui-url"
		ui.render()
		return
	}

	view := "standardview"

	// search view setted on topic parameters
	for _, p := range ui.currentTopic.Parameters {
		if p.Key == "tatwebui.view.restricted" && p.Value != "" {
			view = strings.TrimSpace(strings.Replace(p.Value, "-list", "", 1))
			break
		} else if p.Key == "tatwebui.view.default" && p.Value != "" {
			view = strings.TrimSpace(strings.Replace(p.Value, "-list", "", 1))
		}
	}
	if !strings.HasSuffix(base, "/") {
		view = "/" + view
	}
	url := fmt.Sprintf("%s%s/list%s?idMessage=%s", base, view, ui.currentTopic.Topic, msg.ID)
	open.Run(url)
}
开发者ID:ovh,项目名称:tatcli,代码行数:27,代码来源:events.go

示例15: handle

func handle(conn net.Conn) {
	defer conn.Close()
	log.Printf("Request from %s", conn.RemoteAddr())

	if !firewall.IsAllowed(conn.RemoteAddr()) {
		fmt.Fprintf(conn, "Connect is not allowed from %s", conn.RemoteAddr())
		return
	}

	line, err := bufio.NewReader(conn).ReadString('\000')

	if err != nil {
		log.Println(err)
		conn.Write([]byte(err.Error()))
		return
	}
	body := line[:len(line)-1]

	err = open.Run(string(body))
	if err != nil {
		log.Println(err)
		conn.Write([]byte(err.Error()))
		return
	}
}
开发者ID:pocke,项目名称:remote-open,代码行数:25,代码来源:main.go


注:本文中的github.com/skratchdot/open-golang/open.Run函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。