Shortcut to install libraries in Goland - go

I'm following the instructions in https://golang.org/doc/code.html#Library and trying to use Goland. I'm surprised though that I can't find a fast way to install the library I'm writing. According to the tutorial, you should use install to install your code in the pkg or bin folders, yet I can't find a way to do this in Goland other than writing it in the console.
What am I missing?

There are two ways to import Go packages using GoLand:
copy-paste the code that needs the package into the IDE and then on the import declaration use Show Intention to see the list of actions available and choose the first one, go get -t <package-name>/...
copy the URL of the Github repository into your clipboard, switch to the IDE and use the pop-up to run go get on the package. The pop-up disappears after a few seconds.
I've attached the image which shows these options.
This will download libraries in the correct GOPATH directory and run go install as part of the go get action.
As for installing the libraries that you are developing in GOPATH/pkg, there is no need for that, as soon as you run any configuration from the IDE, be it an application or a test that depend on those libraries, the IDE will install those libraries as well.

Related

Why would this particular package fail to be auto-imported?

I'm using VSCode with a few Go projects, in a workspace. I've got pretty standard VSCode settings, and I'm using the Go extension with gopls.
When in my code I'm using a package which has been installed in my current module, it is auto-imported successfully (i.e. "github.com/gosimple/slug").
But when I'm using spew the auto-import happens to be "app/env/pkg/mod/github.com/davecgh/go-spew#v1.1.1/spew" instead of "github.com/davecgh/go-spew/spew", everytime.
It also happens (only sometimes) with another package, "github.com/google/uuid".
Now I don't think it's related to these particular packages in any way, but I'm struggling to find a cause to this, and why only these packages.
vscode 1.68.1
go 1.18
gopls 0.9.0

Is there an alternative to get the Golang code completion in VS Code without installing Go?

My goal is to use Go exclusively on Docker. In other words, I try my best not to install Go directly to my computer. And, I am writing the code on a VS Code and use the "Go" extension.
The problem is that when I create a main.go it throws an error:
Failed to find the "go" binary in either GOROOT() or PATH(/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin). Check PATH, or Install Go and reload the window. If PATH isn't what you expected, see https://github.com/golang/vscode-go/issues/971
Is there an alternative to get the code completion feature in VS Code?
This should be achievable using the Remote Development Extension pack. VSCode has good documentation on using containers as your development enviroment. This will allow you to enjoy all of the Go extension's features without needing Go to be installed directly on your machine. You can opt to install the extensions in the container as well.
See Developing inside a Container

Auto download new package in golang module project [duplicate]

This question already has answers here:
cannot find package "rsc.io/quote"
(4 answers)
Closed 1 year ago.
I am following a golang book (using go 1.15) which not surprisingly advocates using go modules for dependency management. I have no problem following along until a chapter where it says "because we have module enabled for our project, after adding a new import to our code, we can just do go run and go is clever enough to notice the new import and will auto download the package as well as update the go.mod file for us. We don't need to manually do go get". In book, it appears that this auto download does work as there is screenshot in the book showing the download message.
To clarify, this new import is added for the first time to the project.
This is totally new to me and got me excited but when I tried it, it doesn't work. It says no required module provides package github.com/xxx/yyy; to add it: go get github.com/xxx/yyy;
I obviously have module enabled for the project.
Is there any setting I missed to enable this auto download?
I am using go 1.16
When you create a new project, you must manually add the libraries that you will use via the command:
go get ...
But later, if you run that project in another machine, for example, once the go run command or the go build command, Go will download and add the libraries automatically.
For example, if you download a project from GitHub and run it, it will load and add all the libraries automatically.
All you have to do is type: go run ... or go build

How to create distribution of Python GTK3 app?

I made an application using GTK3 on Windows (Mingw_x64 installation of GTK) and I cannot really figure out how to make a distribution out of this. According to official documentation of PyGObject, it is possible in some way.
I already tried to make a package using setuptools, but PyGObject documentation is not saying much about this process and I was not able to configure setup correctly to make it work. PyGObject has a lot of dependecies and weird imports, that I do not know how to include.
I also tried Pyinstaller, which claims it has GTK support, and it really can pack it into executable, however it is not working. I tried these two options:
make only one file (.exe), but in this situations, it throws an error, that some file is not found (libpixbufloader-ani.dll)
create a directory with all needed files (libpixbufloader-ani.dll and other libs are included this time), but when running exe, another exeption occurs, this time Struct and 2 other libraries are missing (strangely, there is a folder that contains Struct)
Becouse of the missing files, I tried adding as many paths containing needed libraries as possible to Pyinstaller, but without success.
Does anyone have any experience with packaging GTK appliciations in Python? There is definitely a way to do this, but I am not very experienced with packaging. If needed, I can provide more information.
This is an issue that has been brought up on PyInstaller's GitHub page, as others (including myself) have experienced the same issue that you've mentioned.
The last time I tried the dev version of PyInstaller, the issue still wasn't fixed, but I managed to get a working executable by using PyInstaller to find the dependencies that my Python3/GTK3 app needed, and then I used cx_Freeze to generate the final executable.

Build or Compile Webkit on Windows7 64bit

I'm trying to just build webkit on windows. As usual I started with webkit site and trying to get developer tools setup. I'm struck basically at the cygwin Installation itself.
The cygwin-downloader gets all the packages and runs the setup normally.
As per the installation instructions, I selected the Install from Local Directory Option (cygwin install and source package directories are different).
There was some initial turbulance in finding the packages, somehow i could let it find the packages. The screen looks like this now.
I selected the packages (all) and then proceeded with next. It just ran very fast and exited saying nothing needs to be installed. It looked like this.
After I ran the cygwin shorcut from the desktop its shouting something is missing.
I don't understand what am I missing here. Also at some link it says we need a port to build webkit. If thats the case, how does anyone port webkit to their applications without building the webkit alone?
I know this is not a programming question. but this will help most of the people who are taking baby steps in understanding and build WebKit. Thanks!
According to this, it's seems a cygwin-downloader's bug.
However, there is a workaround...
Just copy {cygwin-downloader}\setup.ini file to a {cygwin-downloader}\x86\ directory. Then reopen setup.exe. It will show you a package list without turbulence. You don't need to click all from the package list. Just click Next.

Resources