未解析的方法调用在另一个方法中的引用

时间:2017-03-16 09:24:40

标签: go goland

我想从Seed方法中调用两个方法(seedAccounts和initializeBucket)。有办法吗?它一直在说"未解决的参考"。

这是代码

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 个答案:

答案 0 :(得分:4)

initializeBucket()seedAccounts()BoltClient类型的方法,快速修复:

func (bc *BoltClient) Seed() {
     bc.initializeBucket() 
     bc.seedAccounts()
}