Go client for Google Drive SDK v2 - go

https://developers.google.com/drive/v2/reference/files/list
Are there Go examples using the code.google.com/p/google-api-go-client/drive/v2 package. Is there another location for it? or just not released yet?

It is not yet released, but you can build the client yourself, if you have the library installed with:
go get code.google.com/p/google-api-go-client/drive/v1
cd $GOPATH/src/code.google.com/p/google-api-go-client
go run google-api-go-generator/gen.go -api=drive:v2
go install ./drive/v2
I will submit a patch right now to get it added.

The package is there but not accessible from that URL:
You can browse the code from
http://code.google.com/p/google-api-go-client/source/browse/
and download and install it in you GOPATH

Related

How To Download Client-Go V12.0.0 via Go Get Cmd Tool

when I execute below cmd:
go get k8s.io/client-go#v12.0.0
it tells me: "go: k8s.io/client-go#v12.0.0: invalid version: module contains a go.mod file, so module path must match major version ("k8s.io/client-go/v12")"
ok, then I changed the cmd to this:
go get k8s.io/client-go#v12.0.0+incompatible
then again, it still tells me the same error: go: k8s.io/client-go#v12.0.0+incompatible: invalid version: module contains a go.mod file, so module path must match major version ("k8s.io/client-go/v12")
one interesting thing puzzles me that if I add require k8s.io/client-go v12.0.0+incompatible to go.mod and then execute go mod tidy, then client-go v12.0.0 will be downloaded correctly.
My question is: how can I download this specific version of client-go via go get??
Go Version: v1.18
I used the go install command to download client-go
Here are two examples to install the latest or specific version.
go install k8s.io/client-go#latest
go install k8s.io/client-go#v0.25.3
See client-go installation section for more help,
client-go install
how can I download this specific version of client-go via go get
Not at all.
go get is for adding dependencies to your project.
To download source code in a certain version from the internet use git clone and git checkout.

Can 'go install' be made to work for executables with different names from the git repo?

Go has a nice feature where you can go install <x> and it will download, build and install a binary.
For example, on my local windows PC, go install github.com/goreleaser/goreleaser will find the latest release for goreleaser, download, build and install it to my local binaries path.
I am working on a project where we would like to enable go install, but encounter a problem if the github repo name does not match the executable name. The GitHub CLI itself runs into the exact same problem:
Example:
go install github.com/cli/cli#latest
go: downloading github.com/cli/cli v1.14.0
go: github.com/cli/cli#latest: module github.com/cli/cli#latest found (v1.14.0), but does not contain package github.com/cli/cli
Is there a way to resolve this?
Update: I worked out that I could directly reference the package via it's sub directory. In my particular instance this works: go install github.com/OctopusDeploy/cli/cmd/octopus#latest
This is a bit unpleasant, but works correctly. It doesn't work for the github CLI because their go.mod has a replace directive in it :-(
Question: Can this be made nicer? Is there a way to put some sort of alias or configuration file so that go install github.com/OctopusDeploy/cli#latest can be used instead of go install github.com/OctopusDeploy/cli/cmd/octopus#latest ?
Can this be made nicer? Is there a way to put some sort of alias or configuration file so that go install github.com/OctopusDeploy/cli#latest can be used instead of go install github.com/OctopusDeploy/cli/cmd/octopus#latest ?
No. Dead simple.

Difficulty installing go buffalo using go mod on windows

I am very new to golang. I am trying to work with the gomod. Trying to explore the go buffalo framework. But finding a bit of difficulty in installing that.
What I have done:
I saw that go get is nomore supported for buffalo and so switched to go modules.
Created a module by go mod init github.com/webbuffalotest
Fetched go get -v github.com/gobuffalo/buffalo (on the same directory where I have go.mod file)
Fetched go get -v github.com/mattn/go-sqlite3 (on the same directory where I have go.mod file)
go install github.com/gobuffalo/buffalo
I was expecting a buffalo.exe inside %GOPATH%/bin so that I can add it to my path but didn't find one.
My question is what's wrong? Is the exe not installed or it's somewhere else because of go mod. Any help will be highly appreciated.
I am using windows 10. I am not willing to install package managers as scoop or choco to install buffalo. Thanks for your patience :)
Edited:
Also tried setting set GO111MODULE=on but of no use.
Solved:
My bad, I should have used go install github.com/gobuffalo/buffalo/buffalo instead of go install github.com/gobuffalo/buffalo
github.com/gobuffalo/buffalo is a library; the corresponding binary is (aptly-named) github.com/gobuffalo/buffalo/buffalo.
The go install command you ran should have warned you about that, but didn't because go install used to also be used to cache compiled libraries (it no longer does that in module mode).
I've filed https://golang.org/issue/46912 to add a diagnostic.

Unknown subcommand "mod" error while running go mod init

I have installed the go language in my ubuntu using sudo apt install golang-go.
It was successfully installed. When i run go version I am getting go version go1.10.4 linux/amd64
but when i tried running go mod init projectName I am getting the following error go: unknown subcommand "mod"
Do I need to install mod package or am i missing something? I have implemented the solution given by christophe in this forum but it didn't work for me.
Preliminary module support was added in Go 1.11, so Go 1.10 knows no mod subcommand.
You need to install a newer, preferably the newest 1.14 version of Go. Get it from the official downloads page. Go 1.10 is not even supported anymore (doesn't receive security patches).
The prepared packages of OSes usually lag behind new releases. I'd advise to always get Go from the official page.
Because preliminary support for go-modules came in version 1.11 and 1.12.
More here
I suggest that you install using the linux build directly from golang

go install not creating binary of a package while go get is able to

I am on go version go1.11.2 linux/amd64. When the package godog is installed using go get github.com/DATA-DOG/godog/, godog executable is created inside $GOPATH/bin/. All fine till now.
I am creating an application myApp that resides at $GOPATH/src/ in which under the folder vendor, godog package is added. When I try to create a binary out of vendor-ed package, an archive file is created inside $GOPATH/pkg/linux_amd64/myApp/vendor/github.com/DATA-DOG/ as godog.a
How can I create a binary in this scenario? I do not want to do go get again just for the binary.
go install does not automatically install apps in vendor folders, but you may specify a vendored path explicitly if you wish so. So simply run:
go install myApp/vendor/github.com/DATA-DOG/godog/cmd/godog

Resources