[英]Is it possible to increase the validity of GCP JWT tokens beyond 1 hour? And is there a global API endpoint that I can scope the JWT to?
[英]Why Golang allows circular reference in global scope but not in function scope
当我使用gormigrate编写数据库迁移时,我需要在 function scope 中定义两个结构之间的多对多关系。 但在 golang 1.19 或 1.18 中,以下内容无法编译
package main
import "fmt"
func main() {
type Student struct {
Courses []*Course
// [Error] ./prog.go:7:14: undefined: Course
}
type Course struct {
Students []*Student
}
fmt.Printf("This won't compile")
}
但是,将定义移到 function 之外就可以了
package main
import "fmt"
type Student struct {
Courses []*Course
}
type Course struct {
Students []*Student
}
func main() {
fmt.Printf("This works")
}
可以在https://go.dev/play/p/GI53hhlUTbk自己尝试一下
为什么会这样? 我怎样才能让它在 function scope 中工作?
C++中是否有类似typedef的语法,所以我们可以先声明一个struct,然后再定义它?
谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.