[英]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.