英文:
Unresolved reference of a method call in another method
问题
我想从Seed方法中调用两个方法(seedAccounts和initializeBucket)。有没有办法做到这一点?它一直显示"未解析的引用"。
以下是代码:
type BoltClient struct {
boltDB *bolt.DB
}
func (bc *BoltClient) Seed() {
bc.initializeBucket() // 未解析的引用 initializeBucket
bc.seedAccounts() // 未解析的引用 seedAccounts
}
func (bc *BoltClient) initializeBucket() {
// 代码
}
func (bc *BoltClient) seedAccounts() {
// 代码
}
英文:
I want to call two methods(seedAccounts and initializeBucket) from the Seed method. Is there a way to do it? It keeps saying "Unresolved reference".
Here is the code
type BoltClient struct {
boltDB *bolt.DB
}
func (bc *BoltClient) Seed() {
initializeBucket() //unresolved reference initializeBucket
seedAccounts() // unresolved reference seedAccounts
}
func (bc *BoltClient) initializeBucket() {
//Code
}
func (bc *BoltClient) seedAccounts() {
//Code
}
答案1
得分: 5
initializeBucket()
和seedAccounts()
是BoltClient
类型的方法,快速修复:
func (bc *BoltClient) Seed() {
bc.initializeBucket()
bc.seedAccounts()
}
initializeBucket()
和seedAccounts()
是BoltClient
类型的方法,快速修复:
func (bc *BoltClient) Seed() {
bc.initializeBucket()
bc.seedAccounts()
}
英文:
initializeBucket()
and seedAccounts()
are methods of type BoltClient
, quick fix:
func (bc *BoltClient) Seed() {
bc.initializeBucket()
bc.seedAccounts()
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论