【问题标题】:struggling to compile go project with gogradle努力用 gogradle 编译 go 项目
【发布时间】:2018-08-14 11:58:18
【问题描述】:

我有这个在另一个虚拟机中工作。我使用的工具版本相同:

  • Gradle 4.9
  • Java 8 更新 181
  • golang 1.9.7
  • gogradle 插件 0.10

我收到以下错误:

13:44 $ gradle 构建

> Configure project :
Found go 1.9.7 in /home/phil/dev/tools/go/current/bin/go, use it.

> Task :prepare
Use project GOPATH: /home/phil/dev/projects/misc/go/Notification_System_GO/.gogradle/project_gopath
.gogradle/project_gopath/src/com.misc/notifications/vendor/cloud.google.com/go/pubsub/subscription.go:30:2: cannot find package "golang.org/x/sync/errgroup" in any of:
        /home/phil/dev/projects/misc/go/Notification_System_GO/.gogradle/project_gopath/src/com.misc/notifications/vendor/golang.org/x/sync/errgroup (vendor tree)
        /home/phil/dev/tools/go/go1.9.7/src/golang.org/x/sync/errgroup (from $GOROOT)
        /home/phil/dev/projects/misc/go/Notification_System_GO/.gogradle/project_gopath/src/golang.org/x/sync/errgroup (from $GOPATH)
.gogradle/project_gopath/src/com.misc/notifications/vendor/cloud.google.com/go/pubsub/flow_controller.go:19:2: cannot find package "golang.org/x/sync/semaphore" in any of:
        /home/phil/dev/projects/misc/go/Notification_System_GO/.gogradle/project_gopath/src/com.misc/notifications/vendor/golang.org/x/sync/semaphore (vendor tree)
        /home/phil/dev/tools/go/go1.9.7/src/golang.org/x/sync/semaphore (from $GOROOT)
        /home/phil/dev/projects/misc/go/Notification_System_GO/.gogradle/project_gopath/src/golang.org/x/sync/semaphore (from $GOPATH)
.gogradle/project_gopath/src/com.misc/notifications/vendor/google.golang.org/api/transport/grpc/dial.go:29:2: cannot find package "google.golang.org/grpc/credentials/oauth" in any of:
        /home/phil/dev/projects/misc/go/Notification_System_GO/.gogradle/project_gopath/src/com.misc/notifications/vendor/google.golang.org/grpc/credentials/oauth (vendor tree)
        /home/phil/dev/tools/go/go1.9.7/src/google.golang.org/grpc/credentials/oauth (from $GOROOT)
        /home/phil/dev/projects/misc/go/Notification_System_GO/.gogradle/project_gopath/src/google.golang.org/grpc/credentials/oauth (from $GOPATH)

build.gradle 如下:

plugins {
    id 'com.github.blindpirate.gogradle' version '0.10'
}

golang {
    packagePath = 'com.misc/notifications'
}

dependencies {
    golang {
        build name: 'google.golang.org/appengine', tag: 'v1.1.0'
        build name: 'github.com/golang/protobuf'
        build name: 'github.com/golang/mock'
        build name: 'cloud.google.com/go', tag: 'v0.22.0'
        build name: 'github.com/googleapis/gax-go', tag: '1.0.0'
    }
}

build {
    outputLocation = './bin/notifications'
}

任何帮助将不胜感激

【问题讨论】:

标签: go gradle gcloud


【解决方案1】:

我已将 2 个有问题的库添加到似乎修复它的依赖项中。虽然我不知道为什么......

plugins {
    id 'com.github.blindpirate.gogradle' version '0.10'
}

golang {
    goVersion = '1.9.7'
    packagePath = 'com.misc/notifications'
}

dependencies {
    golang {
        build name: 'google.golang.org/appengine', tag: 'v1.1.0'
        build name: 'github.com/golang/protobuf', tag: 'v1.1.0'
        build name: 'github.com/golang/mock', tag: 'v1.1.0'
        build name: 'cloud.google.com/go', tag: 'v0.24.0'
        build name: 'github.com/googleapis/gax-go', tag: '1.0.0'
        build name: 'github.com/golang/protobuf', tag: 'v1.1.0'
        build name: 'golang.org/x/sync/errgroup', tag: ''
        build name: 'google.golang.org/grpc/credentials/oauth', tag: ''
    }
}

build {
    outputLocation = './bin/notifications'
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 2015-06-07
    • 2018-07-23
    • 2018-01-23
    • 1970-01-01
    • 2020-07-12
    相关资源
    最近更新 更多