• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang clipboard.WriteAll函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: returnPw

func returnPw(pwch chan string) {
	var pwd string
	select {
	case pw := <-pwch:
		pwd = pw
	case <-time.After(750 * time.Millisecond):
		say("Generating...")
		pwd = <-pwch
	}

	if *noTerminal {
		fmt.Print(pwd)
		return
	}

	before, err := clipboard.ReadAll()
	clipboard.WriteAll(pwd)
	say("\nPassword copied to clipboard! ")
	time.Sleep(5 * time.Second)
	say("Cleaning clipboard in 5 seconds...")
	time.Sleep(5 * time.Second)
	if err != nil {
		clipboard.WriteAll("")
	} else {
		clipboard.WriteAll(before)
	}
	say("\n...again? or CTRL+C\n")
}
开发者ID:ionDynamics,项目名称:statelessPassword,代码行数:28,代码来源:frontend.go


示例2: writeToClipboard

func writeToClipboard(buffer *bytes.Buffer) {
	clipboardOutput := buffer.String()
	if clipboardOutput != "" {
		clipboard.WriteAll(clipboardOutput)
		fmt.Printf("nw: wrote \"%s\" to clipboard\n", clipboardOutput)
	}
}
开发者ID:kodybrown,项目名称:numberwang,代码行数:7,代码来源:nw.go


示例3: runAdd

func (app *App) runAdd(login, realm, note string, copyPassword bool) {
	db := app.openStore()
	defer db.Close()

	if login == "" {
		login = readInput("Login: ")
	}

	password := readPasswordConfirm("Password")

	if realm == "" {
		realm = readInput("Realm: ")
	}

	if note == "" {
		note = readInput("Note: ")
	}

	db.AddCredential(&store.Credential{
		Login:    login,
		Password: password,
		Realm:    realm,
		Note:     note,
	})

	printSuccess("Credential added. ")

	if copyPassword {
		clipboard.WriteAll(password)
		fmt.Println("Password copied to the clipboard.")
	} else {
		fmt.Println()
	}
}
开发者ID:schmich,项目名称:ward,代码行数:34,代码来源:add.go


示例4: generateOauthURLAndExit

func (yt *YouTube) generateOauthURLAndExit() {
	// Redirect user to Google's consent page to ask for permission
	// for the scopes specified above.
	url := yt.config.AuthCodeURL("state", oauth2.AccessTypeOffline, oauth2.ApprovalForce)
	clipboard.WriteAll(url)
	log.Fatalln("Visit the following URL to generate an auth code, then rerun with -auth=<code> (It has also been copied to your clipboard):\n%s", url)
}
开发者ID:iopred,项目名称:bruxism,代码行数:7,代码来源:youtube.go


示例5: add

func add(name string, password []byte) error {
	clipboard.WriteAll(string(password))

	p := Password{}
	p.Salt = randBytes(8)

	key = pbkdf2.Key(key, p.Salt, 4096, 32, sha1.New)

	session, err := aes.NewCipher(key)
	if err != nil {
		return err
	}
	password = pad(password)

	pass_ciphered := make([]byte, aes.BlockSize+len(password))
	iv := pass_ciphered[:aes.BlockSize]
	if _, err := io.ReadFull(rand.Reader, iv); err != nil {
		return err
	}

	mode := cipher.NewCBCEncrypter(session, iv)
	mode.CryptBlocks(pass_ciphered[aes.BlockSize:], password)
	p.Pass = pass_ciphered

	logins[name] = p
	return nil
}
开发者ID:jostillmanns,项目名称:passdb,代码行数:27,代码来源:passdb.go


示例6: processClipboard

func processClipboard() {
	val, _ := clipboard.ReadAll()
	if lastClipboardValue != val {
		lastClipboardValue = val
		found := false
		for _, urlPattern := range urls {
			m, _ := regexp.MatchString(
				"\\A"+strings.Replace(urlPattern, "*", "(.*)", -1)+"\\z",
				val)
			if m {
				found = true
				break
			}
		}
		if found {
			go func() {
				min := minify(val)
				if len(min) > 0 {
					clipboard.WriteAll(min)
					lastClipboardValue = min
				}
			}()
		}
	}
}
开发者ID:amazedevil,项目名称:AutoUrlMinifier,代码行数:25,代码来源:main.go


示例7: Example

func Example() {
	clipboard.WriteAll("日本語")
	text, _ := clipboard.ReadAll()
	fmt.Println(text)

	// Output:
	// 日本語
}
开发者ID:maiavb1980,项目名称:clipboard,代码行数:8,代码来源:example_test.go


示例8: writeClipBoard

func writeClipBoard() {
	shortened := <-shortenChan
	err := clipboard.WriteAll(shortened)
	if err != nil {
		log.Fatal(err)
	}
	writerChan <- "wrote " + shortened + " to the clipboard\n"
}
开发者ID:Rakin05,项目名称:ClipShorter,代码行数:8,代码来源:ClipShorter.go


示例9: action

func action(context *cli.Context) {
	text := readClipboard()
	res := httpGet(text)
	json := unmarshal(res)
	if json.Errormessage != "" {
		fmt.Fprintln(os.Stderr, json.Errormessage)
		os.Exit(1)
	}
	clipboard.WriteAll(json.Shorturl)
	fmt.Println("Write the value to clipboard: " + json.Shorturl)
}
开发者ID:hotchemi,项目名称:surl,代码行数:11,代码来源:main.go


示例10: main

func main() {

	out, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	if err := clipboard.WriteAll(string(out)); err != nil {
		panic(err)
	}
}
开发者ID:tobischo,项目名称:kp2,代码行数:11,代码来源:gocopy.go


示例11: CopyToClipboard

func (b *BrowserCode) CopyToClipboard() error {
	encoded, err := b.Encode()
	if err != nil {
		return err
	}
	err = clipboard.WriteAll(encoded)
	if err != nil {
		return err
	}
	return nil

}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:12,代码来源:browsercode.go


示例12: KeyFuncClearBefore

func KeyFuncClearBefore(this *Buffer) Result {
	var killbuf bytes.Buffer
	for i := 0; i < this.Cursor; i++ {
		killbuf.WriteRune(this.Buffer[i])
	}
	clipboard.WriteAll(killbuf.String())
	keta := this.Delete(0, this.Cursor)
	Backspace(keta)
	this.Cursor = 0
	this.Repaint(0, keta)
	return CONTINUE
}
开发者ID:Matsuyanagi,项目名称:nyagos,代码行数:12,代码来源:readline_keyfunc.go


示例13: copyPass

func copyPass(siteName string) {
	decrypted, _ := getDecryptedData()
	value, ok := decrypted[siteName]
	if ok {
		err := clipboard.WriteAll(value)
		check(err)
		fmt.Println("The password has been copied to the clipboard")
	} else {
		fmt.Println("Not found")
		os.Exit(1)
	}
}
开发者ID:eugenijm,项目名称:pm,代码行数:12,代码来源:commands.go


示例14: runGen

func (app *App) runGen(login, realm, note string, copyPassword bool, generator *passgen.Generator) {
	passwordChan := make(chan *passwordResult)
	go func() {
		password, err := generator.Generate()
		passwordChan <- &passwordResult{password: password, err: err}
	}()

	db := app.openStore()
	defer db.Close()

	if login == "" {
		login = readInput("Login: ")
	}

	if realm == "" {
		realm = readInput("Realm: ")
	}

	if note == "" {
		note = readInput("Note: ")
	}

	var result *passwordResult
	select {
	case result = <-passwordChan:
		fmt.Println("Password: (generated)")
	default:
		fmt.Println("Password: (generating)")
		result = <-passwordChan
	}

	if result.err != nil {
		printError("%s\n", result.err)
		return
	}

	db.AddCredential(&store.Credential{
		Login:    login,
		Password: result.password,
		Realm:    realm,
		Note:     note,
	})

	printSuccess("Credential added. ")

	if copyPassword {
		clipboard.WriteAll(result.password)
		fmt.Println("Generated password copied to the clipboard.")
	} else {
		fmt.Println()
	}
}
开发者ID:schmich,项目名称:ward,代码行数:52,代码来源:add.go


示例15: main

func main() {
	r := regexp.MustCompile(`^“([^“”]+)”[^“”]+Excerpt From:[^“”]+“[^“”]+” iBooks.`)
	for true {
		clipContent, _ := clipboard.ReadAll()
		matchedGroups := r.FindStringSubmatch(clipContent)
		if len(matchedGroups) > 0 {
			stripped := matchedGroups[1]
			clipboard.WriteAll(stripped)
			fmt.Println("\n\n" + stripped)
		}
		time.Sleep(50)
	}
}
开发者ID:kindlychung,项目名称:stripibook,代码行数:13,代码来源:main.go


示例16: copyThenClear

func copyThenClear(text string, d time.Duration) error {
	signals := make(chan os.Signal, 1)
	signal.Notify(signals, os.Interrupt, os.Kill)
	defer signal.Stop(signals)
	original, err := clipboard.ReadAll()
	if err != nil {
		return err
	}
	err = clipboard.WriteAll(text)
	if err != nil {
		return err
	}
	select {
	case <-signals:
	case <-time.After(d):
	}
	current, _ := clipboard.ReadAll()
	if current == text {
		return clipboard.WriteAll(original)
	}
	return nil
}
开发者ID:zennro,项目名称:oyster,代码行数:22,代码来源:main.go


示例17: main

func main() {
	var domain, salt, master, note string = "", "", "", ""
	var pass_length int = 14

	if len(os.Args) == 1 {
		fmt.Printf("Usage: %s domain [password-length]\n", os.Args[0])
		os.Exit(1)
	}

	if len(os.Args) > 1 {
		// We do have domain
		domain = strings.TrimSpace(os.Args[1])
		display_notes(domain)
	}

	if len(os.Args) > 2 {
		// We do have password length
		p_length, err := strconv.Atoi(os.Args[2])
		if err != nil {
			fmt.Printf("Password Length should be a number\n")
			os.Exit(1)
		}
		pass_length = p_length
	}

	reader := bufio.NewReader(os.Stdin)

	fmt.Printf("Enter salt. Hit enter to leave it blank: ")
	salt, _ = reader.ReadString('\n')
	salt = strings.TrimRight(salt, "\n")

	fmt.Printf("Enter note to save. Hit enter to leave it blank: ")
	note, _ = reader.ReadString('\n')
	note = strings.TrimRight(note, "\n")

	if len(note) > 0 {
		add_note(domain, note)
	}

	fmt.Printf("Enter Master password. Hit enter to abort: ")
	master = string(gopass.GetPasswdMasked()[:])

	if len(master) == 0 {
		os.Exit(1)
	}

	password := gen_pwd(domain+salt, master)[:pass_length]
	clipboard.WriteAll(password)
	fmt.Println(password, "copied to your clipboard")
}
开发者ID:karteek,项目名称:hap.go,代码行数:50,代码来源:hap.go


示例18: cp

func cp(args []string) {
	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, "Usage: passman cp <service>")
		return
	}
	services, err := loadServices(getPasswd())
	gobro.CheckErr(err, "Password invalid")
	service := services.Get(args[0])
	if service.Name != "" {
		clipboard.WriteAll(service.Password)
	} else {
		fmt.Printf("'%s' not found\n", args[0])
	}
}
开发者ID:seanpont,项目名称:passman,代码行数:14,代码来源:passman.go


示例19: runCopy

func (app *App) runCopy(query []string) {
	db := app.openStore()
	defer db.Close()

	credential := findCredential(db, query)
	if credential == nil {
		return
	}

	clipboard.WriteAll(credential.Password)
	identifier := formatCredential(credential)

	printSuccess("Password for %s copied to the clipboard.\n", identifier)
}
开发者ID:schmich,项目名称:ward,代码行数:14,代码来源:copy.go


示例20: Execute

//Execute runs the current command.
func (c *CopyCommand) Execute(w io.Writer, s Storage) {
	for _, list := range s.Lists {
		for key, entries := range list {
			if key == c.List || c.List == "" {
				for _, entry := range entries {
					for key, value := range entry {
						if key == c.Entry {
							clipboard.WriteAll(value)
						}
					}
				}
			}
		}
	}
}
开发者ID:jamesmillerio,项目名称:goboom,代码行数:16,代码来源:copycommand.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang utils.GetDb函数代码示例发布时间:2022-05-24
下一篇:
Golang clipboard.ReadAll函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap