英文:
cannot use r.Condition.AgeInDays (variable of type int64) as type *int64 in struct literal
问题
当我将Firebase导入到Golang文件中时,我遇到了这个错误。我是一个新手,正在学习Golang,请帮助我修复它们。
我的代码:
package main
import (
"fmt"
"log"
"firebase.google.com/go"
"google.golang.org/api/option"
)
func helloWorld(c *fiber.Ctx) {
c.Send("Hello World")
}
func main() {
// 连接数据库
sa := option.WithCredentialsFile("./webgolang.json")
app, err := firebase.NewApp(context.Background(), nil, sa)
client, err := app.Firestore(context.Background())
if err != nil {
log.Fatalln(err)
}
defer client.Close()
//
app := fiber.New()
app.Get("/", helloWorld)
setupRoutes(app)
app.Listen(4000)
}
这是错误:
C:\Users\HP\go\pkg\mod\cloud.google.com\go\storage@v1.22.1\bucket.go:1504:30: cannot use r.Condition.AgeInDays (variable of type int64) as type *int64 in struct literal
C:\Users\HP\go\pkg\mod\cloud.google.com\go\storage@v1.22.1\bucket.go:1592:30: cannot use rr.Condition.Age (variable of type *int64) as type int64 in struct literal
英文:
when i import firebase to golang file, i see this bug.
I'm a newbie, learning to Golang, please help me to fix them
my code:
package main
import (
"fmt"
"log"
"firebase.google.com/go"
"google.golang.org/api/option"
)
func helloWorld(c *fiber.Ctx) {
c.Send("Hello World")
}
func main() {
//connect db
sa := option.WithCredentialsFile("./webgolang.json")
app, err := firebase.NewApp(context.Background(), nil, sa)
client, err := app.Firestore(context.Background())
if err != nil {
log.Fatalln(err)
}
defer client.Close()
//
app := fiber.New()
app.Get("/", helloWorld)
setupRoutes(app)
app.Listen(4000)
}
it's bug
C:\Users\HP\go\pkg\mod\cloud.google.com\go\storage@v1.22.1\bucket.go:1504:30: cannot use r.Condition.AgeInDays (variable of type int64) as type *int64 in struct literal
C:\Users\HP\go\pkg\mod\cloud.google.com\go\storage@v1.22.1\bucket.go:1592:30: cannot use rr.Condition.Age (variable of type *int64) as type int64 in struct literal
答案1
得分: 8
将云存储版本升级到v1.26.0,所以如果你打开你的go.mod
文件,你应该看到以下内容:
cloud.google.com/go/storage v1.26.0 // indirect
英文:
Upgrade the cloud storage version to v1.26.0, so if you go to your go.mod
file, you should have this:
cloud.google.com/go/storage v1.26.0 // indirect
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论