cannot use r.Condition.AgeInDays (variable of type int64) as type *int64 in struct literal

huangapple go评论85阅读模式
英文:

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

huangapple
  • 本文由 发表于 2022年9月14日 13:25:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/73711881.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定