简体   繁体   English

go 1.18 在 google.cloud

[英]go 1.18 in google.cloud

Description描述

I am trying to install a library from a go v1.18 program to access Google Cloud.我正在尝试从 go v1.18 程序安装一个库以访问 Google Cloud。 Previously, the "go get" command was used, but since version 1.18, it is no longer available.以前,使用“go get”命令,但从 1.18 版本开始,它不再可用。 It seems to use go install, but I get an error when executing the command.好像是用go install,但是执行命令的时候报错。

% go install cloud.google.com/go/bigquery
go: 'go install' requires a version when current directory is not in a module
    Try 'go install cloud.google.com/go/bigquery@latest' to install the latest version

% go install cloud.google.com/go/bigquery@latest
package cloud.google.com/go/bigquery is not a main package

% go install cloud.google.com/go@latest
package cloud.google.com/go is not a main package

Environments环境

% go version
go version go1.18 darwin/amd64

% uname -v
Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64

% sw_vers
ProductName:    macOS
ProductVersion: 12.3.1
BuildVersion:   21E258

Reference参考

bigquery package - cloud.google.com/go/bigquery - pkg.go.dev bigquery package - cloud.google.com/go/bigquery - pkg.go.dev

I tried,我试过了,

Thank you for your support.感谢您的支持。

% go mod init cloud.google.com/go

% go get -u cloud.google.com/go/datacatalog
go: added cloud.google.com/go/datacatalog v1.3.0

% go mod tidy
go: downloading google.golang.org/appengine v1.6.7
go: downloading golang.org/x/sys v0.0.0-20220209214540-3681064d5158


% go mod vendor

% go run catalog.go
package command-line-arguments is not a main package

What should I do next?接下来我该怎么办?

Self resolved.自行解决。 -> change package name "main" -> 更改 package 名称“main”

go install is used to install binary programs available on the package. Usually command line tools. go install 用于安装package上可用的二进制程序。通常是命令行工具。

go get, until go1.18, was used to update packages and install programs, they change it by split in several programs go get,在go1.18之前,都是用来更新包和安装程序的,他们改成split in several programs

Seems there is nothing to install.似乎没有什么可安装的。 Also the main package is not bigquery but cloud.google.com/go另外主要的 package 不是 bigquery 而是 cloud.google.com/go

If you want to install a dependency, if you are using vendorized modules you can do如果你想安装一个依赖项,如果你使用的是供应商模块,你可以这样做

$ go get -u cloud.google.com/go/bigquery $ go 获取 -u cloud.google.com/go/bigquery

$ go mod tidy $ go mod 整洁

$ go mod vendor $ go 模组供应商

If not, you may try it by running go mod init first如果没有,您可以先运行go mod init来尝试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 google.cloud 修复 python“未解决的导入”错误 - How to fix python "unresolved import" -error with google.cloud 无法在 python 脚本中使用 google.cloud(存储) - Unable to use google.cloud (storage) from within a python script 尝试使用来自 google.cloud 的 BigQuery 时出现 ModuleNotFoundError - ModuleNotFoundError when trying to use BigQuery from google.cloud Pycharm 在 google.cloud 的“__init__.pyi”中找不到引用“cloud”,但代码确实执行 - Pycharm cannot find reference `cloud` in "__init__.pyi" for google.cloud, but code does execute 导入错误:无法从 Python fastapi 中的“google.cloud”(未知位置)导入名称“tasks_v2” - ImportError: cannot import name 'tasks_v2' from 'google.cloud' (unknown location) in Python fastapi ImportError:无法从“google.cloud”(未知位置)导入名称“aiplatform” - ImportError: cannot import name 'aiplatform' from 'google.cloud' (unknown location) ModuleNotFoundError:将 Streamlit App 部署到 Heroku 时没有名为“google.cloud”的模块 - ModuleNotFoundError: No module named 'google.cloud' When deploying Streamlit App to Heroku 谷歌云平台 presignURL 使用 Go - Google Cloud Platform presignURL using Go Google Cloud Storage - 并发列出对象 (Go) - Google Cloud Storage - Listing objects concurrently (Go) 谷歌云 SQL + Go Gin 连接超时 200 并发 - Google Cloud SQL + Go Gin connection timeout with 200 concurrent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM