草庐IT

向量检索

全部标签

go - 使用 Gorm 检索有很多问题

当我尝试从播客中取回剧集时,我得到了无效关联[]。不确定我做错了什么。packagemainimport("log""github.com/jinzhu/gorm"_"github.com/mattn/go-sqlite3")typePodcaststruct{IdintTitlestringRssUrlstring`sql:"unique_index"`UrlstringEpisodes[]Episode}typeEpisodestruct{IdintPodcastIDint`sql:"index"`TitlestringUrlstring`sql:"unique_index"`Do

mongodb - 当键包含大写字母时无法使用 mgo 检索值

来自mongoDB的一个数据是{"_id":ObjectId("5536def4e4b0644323e219a8"),"title":"TheTitle","description":"TheDescription","timeStamp":"21/04/2015","category":"news","url":"http://www.example.com","source":"EveningTimes","mainStory":"Thisisthemainstory."}在我的代码中,结构是typeNewsDatastruct{Titlestring`bson:"title"js

go - 如何检索嵌套的 map 值

我想扫描AWSDynamoDB表,然后只提取某个值。这是我的代码:packagemainimport("fmt""github.com/aws/aws-sdk-go/aws""github.com/aws/aws-sdk-go/aws/session""github.com/aws/aws-sdk-go/service/dynamodb")funcmain(){svc:=dynamodb.New(session.New(),&aws.Config{Region:aws.String("us-west-2")})params:=&dynamodb.ScanInput{TableName:

go - 检索模型(结构)列表的通用方法

我正在尝试为我的服务创建基本的CRUD。它基于在结构中创建的数据模型。问题是我真的不想重复CRUD方法的代码。例如,我将ModelA和ModelB定义为结构:typeModelAstruct{IDbson.ObjectId`json:"ID,omitempty"bson:"_id,omitempty"`Slugstring`json:"slug"bson:"slug,omitempty"`Creatorstring`json:"-"bson:"creator,omitempty"`DefaultLanguagestring`json:"defaultLanguage"bson:"def

html - 使用 goquery 从网站检索文本

我有一个大致如下所示的html:MoviesASongForJenny(2015)Rating:PGRunningTime(minutes):77Description:ThisDrama,basedonreallifeevents,tellsthestoryofafamilyaffecteddirectlybythe7/7Londonbombings.Itshowslove,loss,heartacheand...MoreaboutASongForJennyEditASongForJenny#RealityHigh(2017)Rating:PGRunningTime(minutes)

go - emersion/go-imap - 如何检索和列出看不见的消息

我正在尝试使用IMAP协议(protocol)的实现,但似乎无法从邮箱中检索看不见的邮件。这是我的代码。packagemainimport("emailmonitor/util""fmt")funcmain(){serverGmail:=util.NewServerGmail()serverGmail.Connect()serverGmail.Login()serverGmail.ListUnseenMessages()}//-----------------------------------------packageutilimport("io/ioutil""log""net/m

azure - 从服务总线队列检索消息时出错

我尝试使用Go从Azure服务总线队列中提取消息,但在运行代码时出现错误。这是我的代码。funcExample_queue_receive(){ctx,cancel:=context.WithTimeout(context.Background(),10*time.Second)defercancel()connectionString:="Endpoint=sb://{my_service_name}.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey={my_sh

go - 使用 golang 在 google-cloud 数据存储中仅检索具有 key 的特定属性

MyKind有3个实体:FirstName、FamilyName和Email。我只想检索与该实体关联的Key和FirstName。在SQL中像这样:SELECTId,FirstNamefromusers;在go-lang中,我尝试像这样获取Kind中的所有数据q:=datastore.NewQuery(dataKind)然后为了拿到key,我这样做了:键,错误:=q.GetAll(ctx,&users)我不想获取所有属性,而只想获取键和名字。我想知道是否有办法在单个数据存储区查询中执行此操作?正如我之前的问题中提到的,我是go-lang和数据存储的新手。请帮忙

mysql - Go:如何使用 sql/db 包从 mysql 检索多个结果

我正在尝试使用Go中的sql/db包从表中获取数据。我的数据库表包含一个用户名“shaw”。有几行用户名shaw在附加的帖子列中有不同的帖子。我有以下代码:开始:funcReadData()string{db,err:=sql.Open("mysql","user1@/my_db")iferr!=nil{fmt.Println(err)}deferdb.Close()vartweetstringrows,err:=db.Query("selecttweetfrompostswhereusername=?","shaw")iferr!=nil{fmt.Println(err)}defer

json - 检索嵌套 Json 数组的第一条记录

我正在尝试解析嵌入式JSON数组中的第一条记录,并根据这些属性的子集创建一个对象。我有这个工作,但基于这个question,我不得不认为有一种更优雅/不那么脆弱的方法可以做到这一点。更多背景信息,这是调用musicbrainz的结果集JSONWeb服务,我将第一个artists记录视为我正在寻找的艺术家。JSON的格式是这样的:{"created":"2014-10-08T23:55:54.343Z","count":458,"offset":0,"artists":[{"id":"83b9cbe7-9857-49e2-ab8e-b57b01038103","type":"Group"