草庐IT

assert_not

全部标签

go - Confluent Kafka Golang 客户端生产者 "Broker: Not enough in-sync replicas"

我正在尝试测试生产者使用Golang客户端向kafka集群上的主题写入消息。这可以很好地写入本地集群上的主题,我只是复制并粘贴了他们的示例代码githubrepo.packagemainimport("fmt""gopkg.in/confluentinc/confluent-kafka-go.v1/kafka")funcmain(){p,err:=kafka.NewProducer(&kafka.ConfigMap{"bootstrap.servers":"localhost"})iferr!=nil{panic(err)}deferp.Close()//Deliveryreporth

gorename : What is a 'DO NOT EDIT' marker?

我正在使用vscode并尝试重命名变量名称。它没有说:Renamefailed:gorename:cannotrenameidentifiersingeneratedfilecontainingDONOTEDITmarker:/home/adam/go/src/hello/hello.go那么什么是DONOTEDIT标记?为什么它在那里,我怎样才能删除它以便gorename可以做它的事情?我的文件是这样开始的:packagemain//#cgoCFLAGS:-g-Wall//#include//#include"c/greet.h"import"C"import("encoding/j

go - 如何修复 VS Code 错误 : "Not able to determine import path of current package by using cwd" for Go project

我正在学习教程,我想我可能错过了一些东西。我有一个Go项目位于:/Users/just_me/development/testing/golang/example_server内容是:main.gopackagemainimport"fmt"funcmain(){fmt.Println("hiworld")}我有一个~/go目录。goenv显示:GOPATH="/Users/just_me/go"GOROOT="/usr/local/Cellar/go/1.12.9/libexec"我在VSCode中安装了建议的包。当我保存我的main.go时,我得到:Notabletodetermi

go - 错误 "protoc-gen-go: program not found or is not executable"

我正在尝试使用Go构建示例应用程序gRPC,但我无法使用“协议(protocol)”生成代码我已经使用以下方法安装了所需的库和Go包:goget-ugoogle.golang.org/grpcgoget-ugithub.com/golang/protobuf/protoc-gen-go我也试过设置路径,但没有成功。示例“原型(prototype)”文件:syntax="proto3";packagegreet;optiongo_package="greetpb";serviceGreetService{}错误信息:"protoc-gen-go:programnotfoundorisno

templates - Golang 模板.ParseFiles "not a directory"错误

我试图只渲染一个模板:root_path,err:=osext.Executable()iferr!=nil{returnerr}template_path:=root_path+"/app/views/mailtemplates/"+"feedback.html"fmt.Println(exist(template_path))tmpl,err:=template.ParseFiles(template_path)iferr!=nil{returnerr}但是我有错误notadirectory。我的存在函数:funcexist(file_pathstring)bool{if_,err

go - 如何修复这个简单程序中的 'declared but not used' 编译器错误?

我正在努力学习围棋。我真的不明白为什么编译器说我没有使用变量。在我看来,我正在使用该变量作为Println的参数。我的教科书说:Inthisforloopirepresentsthecurrentpositioninthearrayandvalueisthesameasx[i]packagemainimport"fmt"funcmain(){x:=[5]float64{1,2,3,4,5}i:=0vartotalfloat64=0fori,value:=rangex{total+=valuefmt.Println(i,value)}fmt.Println("Average:",tota

time - 戈朗 : throttle (time delay) function is not working in goroutine (works fine in main thread)

所以我正在编写一个实用程序来查询工作中的API,它们将每10秒限制为20次调用。很简单,我会将我的通话时间限制在自上次通话后至少0.5秒。在我尝试使用goroutine之前,我的Throttle实用程序运行良好。现在我正在使用结构/方法组合:func(c*CTKAPI)Throttle(){ifc.Debug{fmt.Println("\t\t\tEnteringThrottle()")}for{//incasesomethingelsemakesacallwhilewe'resleeping,weneedtore-checkift:=time.Now().Sub(c.LastCall

Go type assert nil 到指针类型

这个问题在这里已经有了答案:ConvertnilinterfacetopointerofsomethinginGolang?(1个回答)关闭7年前。为什么我不能将nil类型断言为指针类型?这背后的逻辑是什么?packagemainfuncmain(){varsinterface{}=nilvarp*string=nilvarq*string=s.(*string)_=q_=p}

go - Youtube Content ID API 总是返回 Not Found

我的帐户已连接到CMS,但我在API库中看不到YoutubeContentID。但是,我在启用的API中看到了它!!(它出现在我尝试YoutubeContentIDAPI引用文档中的“使用OAuth2.0授权请求”之后)。我可以在引用文档中测试API,它会显示来self的CMS的数据。但是当我从我的程序中调用API时,响应总是这样的:{"error":{"errors":[{"domain":"global","reason":"notFound","message":"NotFound"}],"code":404,"message":"NotFound"}}这是我使用Go实现的:fu

google-app-engine - 来自 Google App Engine 的 Google Cloud SQL(第二代)出现 "TLS requested but server does not support TLS"错误?

我在重用我的连接字符串(已在此处解决...CannotconnecttoGoogleCloudSQLusingSSL+GolangfromGoogleAppEngine...)时遇到问题,连接到GoogleCloudSQL第一代实例,同时尝试连接到第二代实例。我收到此错误:已请求TLS,但服务器不支持TLS我不知道如何解决这个问题,而且文档非常稀少。我发现Instanceconnectionname在第二代上遵循不同的结构,但这似乎不是问题所在。有人解决了吗?我正在从Golang连接。 最佳答案 AppEngine标准环境和第二代C