草庐IT

sql导入

全部标签

go - 是否可以从模块导入 ~/go/src/中的本地包?

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭3年前。Improvethisquestion我使用的是go模块,文件结构是这样的:~/some_path/goapp/go.mod~/some_path/goapp/go.sum~/some_path/goapp/main.go~/go/src/fakedomain.com/fakeuser/foo/foo.go在main.go中,我尝试做i

mysql - SQL 为 WHERE IN 做准备

这个问题在这里已经有了答案:PDObindingvaluesforMySQLINstatement[duplicate](8个答案)关闭8年前。当我们编写Web应用程序时,我们将使用SQL准备而不是连接SQL字符串来避免SQL注入(inject)。例如:sql.exec("select*fromuserwhereuser_id=?",user_id)但是如何在SQL中编写prepareWHERE...IN呢?例如:sql.exec("select*fromuserwhereuser_idin?",user_ids)如果不可能。在这种情况下,避免SQL注入(inject)的正确方法是什么

go - 如何在 Go 源代码目录中列出导入的模块

是否有工具或最简单的方法来列出go源代码目录中的所有导入包?例如:$golist_importsa_directory/github.com/bla/blagithub.com/foo/barLOCAL/module/path 最佳答案 啊找到了way..golist-f'{{join.Deps"\n"}}'|xargsgolist-f'{{ifnot.Standard}}{{.ImportPath}}{{end}}'|sort|uniq 关于go-如何在Go源代码目录中列出导入的模块,

sql - gorp: "auto_increment"附近:语法错误

我正在尝试编写简单的程序以使用gorp将行插入表中,但在创建表时出现错误。代码如下:packagemainimport_"github.com/mattn/go-sqlite3"import"database/sql"import"fmt"import"github.com/go-gorp/gorp"funcmain(){typePersonstruct{Identiint64Createdint64FNamestringLNamestring}db,_:=sql.Open("sqlite3","mydb.db")dbmap:=&gorp.DbMap{Db:db,Dialect:gor

go - 如何更改导入文件?

我在golang中有以下功能:import("github.com/aws/aws-sdk-go/service/iam""github.com/aws/aws-sdk-go/aws/session""fmt")funcNewIAM()*SphinxIAM{//awsConfig:=aws.NewConfig()sess,err:=session.NewSession()iferr!=nil{fmt.Println("Failedtocreatesession,",err)returnnil}session:=&SphinxIAM{iam:iam.New(sess)}returnses

Go导入返回 "unused import"

我是goLang的新手。我正在尝试从intellij构建一个项目,该项目使用git库中的一个包:import("github.com/aerospike/aerospike-client-go")但我得到:“未使用的导入”我已经将我的gopath设置为\users\myuser\go并将其添加到intelij设置中,但我现在unusedimport并且项目无法识别第3方对象。我应该将模块导入我的解决方案吗?我看到它存在于文件系统中:\users\myuser\src\github.com\aerospike\aerospike-client-go你能帮帮我吗?谢谢

sql - 执行查询 sql 时出错 - Golang

我尝试使用来自golang的原生sqlapi在Golang中执行此查询。typeDBstruct{*sql.DB}typeIUserinterface{CreateUserTable()(sql.Result,error)}//InitDBinitializesthedatabasefuncInitDB()*DB{db,err:=sql.Open(dbDriver,dbName)iferr!=nil{log.Fatal("failedtoinitializedatabase:",err)}err2:=db.Ping()iferr2!=nil{log.Fatal(err2)}//vard

sql - 一行的多个条件如果不存在则返回 NULL postgresql

我有这样的架构:[ad_id].[name].[valueofname]1.name."brian"1.age."23"2.job."IT"2.name."Jack"行名称包含多个值:年龄、姓名、生日、工作、年龄我想将其转换为:[ad_id].[name].[age].[birthday].[job][valueofad_id][valueofname][valueofnameofage][valueofnameofbirth][valueofnameofjob]我在下面做了这个查询选择来修复它,所以在我的程序中我必须得到结果ad_id='xxxx'代表每个whenname='name

postgresql - 非标准导入 github.com/lib/pq"in statdard package

这个问题在这里已经有了答案:golangwhatisimportsideeffect(1个回答)Whatdoesanunderscoreinfrontofanimportstatementmean?(5个答案)Importsideeffects(1个回答)关闭4年前。我一直遇到这个问题,我不明白为什么封装模型import("database/sql""fmt"_"github.com/lib/pq")const(host="localhost"port=5432user="postgres"password="postgres"dbname="postgres")vardb*sql.D

go - 单元测试不覆盖本地导入包

我是golang的新手,想了解如何让这个场景发挥作用?这是我的结构GOPATH设置为/Users/xyz/project/Users/xyz/project/src/main.go//importcalculatorandcallSUMwithtwointegeres/Users/xyz/project/src/main_test.go//testfunction/Users/xyz/project/src/calculator/sum.go//SUMfunction(addtwointegers)我有一个主要的go文件,它导入“计算器”,这是一个本地包。当我运行时gotest-cov