【问题标题】:no exported names in the package "src/github.com/rohankeskar19/android_whisper"包“src/github.com/rohankeskar19/android_whisper”中没有导出的名称
【发布时间】:2020-03-15 17:19:18
【问题描述】:

我正在尝试从我的 go 程序中为 android 生成一个绑定,但 gomobile 给了我一个错误,因为

no exported names in the package "src/github.com/rohankeskar19/android_whisper"

这是我使用的命令

gomobile bind -v -target=android -o ethereumchat.aar src\github.com\rohankeskar19\android_whisper\

这是我的文件夹结构

bin
pkg
src
   |
    -github.com/
      |
       -rohankeskar19/
         |
          -android_whisper/
           |
            -ethereumchat.go

我知道要导出名称,它们必须以大写字母开头

这是我的代码

package ethereumchat

import (
    "log"
    "context"
    "fmt"
    "github.com/ethereum/go-ethereum/whisper/shhclient"
)


func Newkeypair(address string) string {
    client, err := shhclient.Dial(address)
    if err != nil{
        log.Fatal(err)
        return "Error occured while connecting to whisper"
    }
    keyID, err := client.NewKeyPair(context.Background())
    if err != nil {
        log.Fatal(err)
        return "Error occured while creating key pair"
    }

    return keyID
}



【问题讨论】:

    标签: android go gomobile


    【解决方案1】:

    为您的包使用与其所在文件夹相同的名称。 (你的包是 ethereumchat 但目录是 andorid_whisper。)

    【讨论】:

    • 这就是我在包中没有导出名称的情况unable to import bind/java: go [-e -json -compiled=true -test=false -export=false -deps=false -find=true -- golang.org/x/mobile/bind/java]: exit status 2: go: finding golang.org/x/mobile latest # runtime/cgo gcc_android.c:6:25: fatal error: android/log.h: No such file or directory #include <android/log.h>
    猜你喜欢
    • 2017-06-10
    • 2015-07-19
    • 1970-01-01
    • 2011-08-31
    • 1970-01-01
    • 1970-01-01
    • 2017-01-04
    • 2020-05-28
    • 2011-03-14
    相关资源
    最近更新 更多