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

Golang internal.Check函数代码示例

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

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



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

示例1: topicTruncate

func topicTruncate(topic string) {
	j := tat.TopicNameJSON{Topic: topic}
	if force {
		out, err := internal.Client().TopicTruncate(j)
		internal.Check(err)
		if internal.Verbose {
			internal.Print(out)
		}
	} else {
		fmt.Print("Are you really sure ? You will delete all messages even if a user has a message in his tasks. Please enter again topic name to confirm: ")
		var confirmTopic string
		fmt.Scanln(&confirmTopic)

		if confirmTopic == topic {
			fmt.Printf("Please enter 'yes' to confirm removing all messages from %s: ", topic)
			var confirmYes string
			fmt.Scanln(&confirmYes)
			if confirmYes == "yes" {
				out, err := internal.Client().TopicTruncate(j)
				internal.Check(err)
				internal.Print(out)
				return
			}
		} else {
			fmt.Printf("Error. You enter %s instead of %s\n", confirmTopic, topic)
		}
		fmt.Println("Nothing done")
	}
}
开发者ID:ovh,项目名称:tatcli,代码行数:29,代码来源:truncate.go


示例2: writeTemplate

func writeTemplate() {
	var templateJSON TemplateJSONType

	if viper.GetString("username") != "" {
		templateJSON.Username = viper.GetString("username")
	}
	if viper.GetString("password") != "" {
		templateJSON.Password = viper.GetString("password")
	}
	if viper.GetString("url") != "" {
		templateJSON.URL = viper.GetString("url")
	}
	if viper.GetString("tatwebui-url") != "" {
		templateJSON.TatwebuiURL = viper.GetString("tatwebui-url")
	}

	jsonStr, err := json.MarshalIndent(templateJSON, "", "  ")
	internal.Check(err)
	jsonStr = append(jsonStr, '\n')
	filename := internal.ConfigFile

	dir := path.Dir(filename)
	if _, err := os.Stat(dir); os.IsNotExist(err) {
		internal.Check(os.Mkdir(dir, 0740))
	}

	internal.Check(ioutil.WriteFile(filename, jsonStr, 0600))
	fmt.Printf("%s is written\n", filename)
}
开发者ID:ovh,项目名称:tatcli,代码行数:29,代码来源:write.go


示例3: socketRead

func socketRead(c *websocket.Conn) {
	for {
		_, r, err := c.ReadMessage()
		internal.Check(err)
		fmt.Print(color(string(r)))
	}
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:7,代码来源:interactive.go


示例4: newClient

func newClient() *websocket.Conn {
	internal.ReadConfig()
	if viper.GetString("url") == "" {
		fmt.Fprintf(os.Stderr, "Invalid Configuration: invalid URL. See tatcli config --help\n")
		os.Exit(1)
	}

	i := strings.Index(viper.GetString("url"), ":")
	endURL := viper.GetString("url")[i:] + "/socket/ws"

	url := "ws" + endURL
	dialer := websocket.DefaultDialer
	if internal.IsHTTPS() {
		url = "wss" + endURL
		dialer = &websocket.Dialer{
			TLSClientConfig:  internal.GetTLSConfig(),
			HandshakeTimeout: time.Duration(time.Duration(time.Second) * 9),
		}
	}

	r, _ := http.NewRequest("GET", url, nil)
	r.Header.Add("Content-Type", "application/json")

	c, _, err := dialer.Dial(url, r.Header)
	internal.Check(err)
	fmt.Printf("Connected to %s [Ctrl+c to quit]\n", url)

	wsActionConnect(c)
	return c
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:30,代码来源:socket.go


示例5: topicDeleteParameter

func topicDeleteParameter(topic string, keys []string) {
	for _, key := range keys {
		t := topicParameterJSON{Topic: topic, Key: key, Recursive: recursive}
		jsonStr, err := json.Marshal(t)
		internal.Check(err)
		internal.PutWant("/topic/remove/parameter", jsonStr)
	}
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:8,代码来源:delete_parameter.go


示例6: topicAddParameter

func topicAddParameter(topic string, parameters []string) {
	for _, param := range parameters {
		parameterSplitted := strings.Split(param, ":")
		if len(parameterSplitted) != 2 {
			continue
		}
		_, err := internal.Client().TopicAddParameter(topic, parameterSplitted[0], parameterSplitted[1], recursive)
		internal.Check(err)
	}
}
开发者ID:ovh,项目名称:tatcli,代码行数:10,代码来源:add_parameter.go


示例7: userVerify

func userVerify(username, tokenVerify string) {
	verifyJSON, err := internal.Client().UserVerify(username, tokenVerify)
	internal.Check(err)

	// Display return to user (contains clear password)
	internal.Print(verifyJSON)

	if save && verifyJSON.Password != "" && verifyJSON.Username != "" && verifyJSON.URL != "" {
		verifyJSON.Message = ""
		jsonStr, err := json.MarshalIndent(verifyJSON, "", "  ")
		internal.Check(err)
		jsonStr = append(jsonStr, '\n')
		filename := internal.ConfigFile
		dir := path.Dir(filename)
		if _, err := os.Stat(dir); os.IsNotExist(err) {
			internal.Check(os.Mkdir(dir, 0740))
		}
		internal.Check(ioutil.WriteFile(filename, jsonStr, 0600))
	}
}
开发者ID:ovh,项目名称:tatcli,代码行数:20,代码来源:verify.go


示例8: topicAddDeleteGroups

func topicAddDeleteGroups(method string, topic string, groups []string, path string) {
	for _, groupname := range groups {
		t := topicGroupnameJSON{topic, groupname, recursive}
		jsonStr, err := json.Marshal(t)
		internal.Check(err)
		if method == "PUT" {
			internal.PutWant("/topic"+path, jsonStr)
		} else {
			internal.DeleteWant("/topic"+path, jsonStr)
		}
	}
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:12,代码来源:topic.go


示例9: groupAddDeleteUsers

func groupAddDeleteUsers(method string, groupname string, users []string, path string) {
	for _, username := range users {
		t := groupUsernameJSON{groupname, username}
		jsonStr, err := json.Marshal(t)
		internal.Check(err)
		if method == "PUT" {
			internal.PutWant("/group"+path, jsonStr)
		} else {
			internal.DeleteWant("/group"+path, jsonStr)
		}
	}
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:12,代码来源:add_admin_user.go


示例10: userReset

func userReset(username, email string) {
	ssl := ""
	if internal.SSLInsecureSkipVerify {
		ssl = "--sslInsecureSkipVerify=true"
	}

	m := userJSON{
		Username: username,
		Email:    email,
		Callback: fmt.Sprintf("tatcli %s --url=:scheme://:host::port:path user verify --save :username :token", ssl),
	}
	jsonStr, err := json.Marshal(m)
	internal.Check(err)
	fmt.Printf(internal.PostWant("/user/reset", jsonStr))
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:15,代码来源:reset.go


示例11: userVerify

func userVerify(username, tokenVerify string) {
	url := fmt.Sprintf("/user/verify/%s/%s", username, tokenVerify)
	r := internal.GetWantReturn(url)

	var verifyJSON verifyJSON
	err := json.Unmarshal([]byte(r), &verifyJSON)
	internal.Check(err)

	// Display return to user (contains clear password)
	fmt.Printf(r)

	if save && verifyJSON.Password != "" && verifyJSON.Username != "" && verifyJSON.URL != "" {
		verifyJSON.Message = ""
		jsonStr, err := json.MarshalIndent(verifyJSON, "", "  ")
		internal.Check(err)
		jsonStr = append(jsonStr, '\n')
		filename := internal.ConfigFile
		dir := path.Dir(filename)
		if _, err := os.Stat(dir); os.IsNotExist(err) {
			internal.Check(os.Mkdir(dir, 0740))
		}
		internal.Check(ioutil.WriteFile(filename, jsonStr, 0600))
	}
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:24,代码来源:verify.go


示例12: messageAction

func messageAction(action, topic, idReference, message, option string) {
	m := messageActionJSON{message, idReference, action, option}
	jsonStr, err := json.Marshal(m)
	internal.Check(err)
	if action == "remove" {
		internal.DeleteWant("/message/"+idReference, nil)
	} else if action == "like" || action == "unlike" ||
		action == "label" || action == "unlabel" ||
		action == "task" || action == "untask" ||
		action == "tag" || action == "untag" ||
		action == "update" {
		internal.PutWant("/message"+topic, jsonStr)
	} else {
		fmt.Print(internal.PostWant(fmt.Sprintf("/message%s", topic), jsonStr))
	}
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:16,代码来源:message.go


示例13: topicParam

func topicParam(topic string, maxLength int, canForceDate, canUpdateMsg, canDeleteMsg, canUpdateAllMsg, canDeleteAllMsg, isROPublic bool) {
	t := paramJSON{
		Topic:           topic,
		MaxLength:       maxLength,
		CanForceDate:    canForceDate,
		CanUpdateMsg:    canUpdateMsg,
		CanDeleteMsg:    canDeleteMsg,
		CanUpdateAllMsg: canUpdateAllMsg,
		CanDeleteAllMsg: canDeleteAllMsg,
		IsROPublic:      isROPublic,
		Recursive:       recursive,
	}
	jsonStr, err := json.Marshal(t)
	internal.Check(err)
	internal.PutWant("/topic/param", jsonStr)
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:16,代码来源:parameter.go


示例14: socketInteractive

func socketInteractive() {
	c := newClient()

	done := make(chan bool)
	go socketRead(c)

	r := bufio.NewReader(os.Stdin)
	go func() {
		for {
			line, err := r.ReadString('\n')
			if err != nil && err.Error() != "unexpected newline" {
				internal.Check(err)
			}
			line = analyzeLine(c, line)
			if line != "" {
				if err = c.WriteMessage(1, []byte(line)); err != nil {
					fmt.Fprintf(os.Stderr, "%s\n", err.Error())
				}
			}
		}
	}()
	<-done
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:23,代码来源:interactive.go


示例15: setAdminUserAction

func setAdminUserAction(username string) {
	m := usernameUserJSON{username}
	jsonStr, err := json.Marshal(m)
	internal.Check(err)
	internal.PutWant("/user/setadmin", jsonStr)
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:6,代码来源:set_admin.go


示例16: groupCreate

func groupCreate(group, description string) {
	m := groupJSON{group, description}
	jsonStr, err := json.Marshal(m)
	internal.Check(err)
	internal.PostWant("/group", jsonStr)
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:6,代码来源:create.go


示例17: checkUserAction

func checkUserAction(username string, fixPrivateTopics, fixDefaultGroup bool) {
	m := checkUserJSON{username, fixPrivateTopics, fixDefaultGroup}
	jsonStr, err := json.Marshal(m)
	internal.Check(err)
	fmt.Println(internal.ReqWant("PUT", http.StatusCreated, "/user/check", jsonStr))
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:6,代码来源:check.go


示例18: renameUserAction

func renameUserAction(username, newUsername string) {
	m := renameUserJSON{username, newUsername}
	jsonStr, err := json.Marshal(m)
	internal.Check(err)
	internal.PutWant("/user/rename", jsonStr)
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:6,代码来源:rename.go


示例19: userAdd

func userAdd(username, email, fullname string) {
	m := userJSON{username, fullname, email, "tatcli --url=:scheme://:host::port:path user verify --save :username :token"}
	jsonStr, err := json.Marshal(m)
	internal.Check(err)
	fmt.Printf(internal.PostWant("/user", jsonStr))
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:6,代码来源:add.go


示例20: topicCreate

func topicCreate(topic, description string) {
	m := topicJSON{topic, description}
	jsonStr, err := json.Marshal(m)
	internal.Check(err)
	internal.PostWant("/topic", jsonStr)
}
开发者ID:bnjjj,项目名称:tatcli,代码行数:6,代码来源:create.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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