草庐IT

int_task_type_id

全部标签

sql - 更新 postgresql 返回 id

最初我认为这是一个heroku问题,因为某些奇怪的原因这段代码在本地运行良好,但在进一步调查后我意识到id一直返回0。本质上,我正在尝试编写一个返回id的更新插入。我正在使用sql库。--------------------------------Tablestructureforbooks------------------------------DROPTABLEIFEXISTS"public"."books"CASCADE;CREATETABLE"public"."books"("id"serialprimarykey,"title"varchar(255)NOTNULLCOLL

pointers - 我如何在 Go 中做一个文字 *int64?

我有一个带有*int64的结构类型field。typeSomeTypestruct{SomeField*int64}在我的代码中的某个时候,我想声明一个文字(比如,当我知道所说的值应该是0,或者指向0时,你知道我的意思)instance:=SomeType{SomeField:&0,}...除了这不起作用./main.go:xx:cannotuse&0(type*int)astype*int64infieldvalue所以我试试这个instance:=SomeType{SomeField:&int64(0),}...但这也不起作用./main.go:xx:cannottakethead

mongodb - 使用 go 在 mongodb 中复制 Id

我正在尝试使用Mongodb在Go中编写一个简单的网络应用程序。我创建了一个简约的简单模型/Controller设置。我可以使用POST和url"/user"以及诸如'{"pseudo":"bobby1"}'之类的数据来创建新用户。用户已创建。但是,当查看Mongodbshell内部时,我得到:{"_id":ObjectId("5616d1ea56ca4dbc03bb83bc"),"id":ObjectId("5616d1ea5213c64824000001"),"pseudo":"bobby2"}“id”字段来self的结构,“_id”字段来自Mongodb。通过查看不同的示例代码,

go - 编写 CLI : How to avoid showing the typed password on screen

这个问题在这里已经有了答案:getpasswdfunctionalityinGo?(11个答案)关闭7年前。我正在使用Go编写命令行工具,其中一个命令将查询用户的用户名和密码(并将其保存到主目录内的配置文件中)。目前我还不知道如何将键入的密码替换为“*”,甚至无法像许多命令行工具那样不键入任何内容。在使用golang时如何做到这一点?

mongodb - 如何将 BSON _Id 分配给 cookie(Go,Mongodb)

我正在尝试创建一个gocookie。我想从Mongodb分配Id以存储在Cookie中。但是在编译时出现如下错误:-“结构文字中的未知http.Cookie字段‘Id’”以下是我的代码:-getUser:=user.CheckDB()expiration:=time.Now().Add(365*24*time.Hour)//TheErrorisCausedbytheNextLinecookie:=http.Cookie{Id:getUser[0].Id,Name:getUser[0].Email,Value:getUser[0].Password,Expires:expiration}

go - 从 Golang 中的二进制文件中读取 int16

我目前正在开发一个从标准输入读取16位整数的Golang程序。我期望值介于3和~128之间,但是,当我打印出整数值时,它是完全随机的,从30,000+到-30,000。我通过执行以下操作在PHP中做同样的事情:这成功了。我正在处理的Go代码位于GitHub上:https://github.com/uniquoooo/dca/blob/decoding/main.go#L502-L536我正在使用bash管道(例如cattestfile|command)将内容通过管道传输到程序中。这是一些测试Golang代码:packagemainimport("bufio""fmt""encoding

go - 关于 "cannot use time.Now() (type time.Time) as type "

使用以下类型定义获取“不能使用time.Now()(类型time.Time)作为字段值中的类型typetime”import("time")typetypetimetime.TimetypeFriendsstruct{NamestringBirthdaytypetime}John:=Friends{Name:"John",Birthday:time.Now()}如果我用直接类型形式(time.Time)替换typetime,就没有问题。GO的规则背后是什么??:> 最佳答案 time.Time和typetime是不同的类型(尽管它们

arrays - 如何在 Go 中创建一个 map[string] [2]int?

这个问题在这里已经有了答案:Cannotassigntopairinamap(3个答案)关闭6年前。我想在Go中创建一个map[string][2]int。我试过this在Playground,但我遇到了错误。我该如何解决这个问题?fmt.Println("Hello,playground")m:=make(map[string][2]int)m["hi"]={2,3}m["heello"][1]=1m["hi"][0]=m["hi"][0]+1m["h"][1]=m["h"][1]+1fmt.Println(m)

arrays - 如何在 Golang 中将字符串转换为 map[int]string

我在将字符串转换为map时遇到了问题。我有来自url的下一个数据map[start:0draw:1length:10_:1475090278299search[value]:search[regex]:falseorder[0][dir]:ascorder[0][column]:0columns[0][orderable]:truecolumns[0][searchable]:truecolumns[0][search][value]:columns[0][search][regex]:falsecolumns[0][data]:namecolumns[0][name]:columns

戈朗 : building interfaces for existing types to make code testable

为了使调用sql包的代码可测试,我构建了以下2个接口(interface):typeDatabaseinterface{Close()errorQuery(string,...interface{})(DatabaseRows,error)}typeDatabaseRowsinterface{Close()errorNext()boolScan(...interface{})error}我要测试的实际代码是:funcgetDatabase(connectionStringstring)(dbDatabase,errerror){ifdb,err=sql.Open("mysql",con