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

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

Unresolved reference of a method call in another method

问题

我想从Seed方法中调用两个方法(seedAccounts和initializeBucket)。有没有办法做到这一点?它一直显示"未解析的引用"。

以下是代码:

  1. type BoltClient struct {
  2. boltDB *bolt.DB
  3. }
  4. func (bc *BoltClient) Seed() {
  5. bc.initializeBucket() // 未解析的引用 initializeBucket
  6. bc.seedAccounts() // 未解析的引用 seedAccounts
  7. }
  8. func (bc *BoltClient) initializeBucket() {
  9. // 代码
  10. }
  11. func (bc *BoltClient) seedAccounts() {
  12. // 代码
  13. }
英文:

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

  1. type BoltClient struct {
  2. boltDB *bolt.DB
  3. }
  4. func (bc *BoltClient) Seed() {
  5. initializeBucket() //unresolved reference initializeBucket
  6. seedAccounts() // unresolved reference seedAccounts
  7. }
  8. func (bc *BoltClient) initializeBucket() {
  9. //Code
  10. }
  11. func (bc *BoltClient) seedAccounts() {
  12. //Code
  13. }

答案1

得分: 5

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

  1. func (bc *BoltClient) Seed() {
  2. bc.initializeBucket()
  3. bc.seedAccounts()
  4. }

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

  1. func (bc *BoltClient) Seed() {
  2. bc.initializeBucket()
  3. bc.seedAccounts()
  4. }
英文:

initializeBucket() and seedAccounts() are methods of type BoltClient, quick fix:

  1. func (bc *BoltClient) Seed() {
  2. bc.initializeBucket()
  3. bc.seedAccounts()
  4. }

huangapple
  • 本文由 发表于 2017年3月16日 17:24:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/42829900.html
匿名

发表评论

匿名网友

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

确定