DEV Community

David Satime Wallin
David Satime Wallin

Posted on

4 1

Go -mess with flatpak+vscode

Made a fresh fedora 28 install on my macbook pro today (yes I'm an osx hater) and decided to install vscode (me too went from emacs to vscode) through flatpak - which I had yet to try out.

Now the basic install of vscode is a one-liner. Simply do flatpak install flathub com.visualstudio.code and you're done. The trouble arose when I installed the go extension.

Normally this is a one-step-thing as well but this time I couldn't get the darn thing to find the go binary. I use fish as my shell and started to suspect it did not find the environment variables correctly (since vscode initiates an sh-shell of its own). So, perhaps noob-ishly, I started setting my PATH, GOPATH and GOROOT in .bash_profile as well. This actually made a difference. I could now see the correct path in the vscode terminal. The strange thing was that, ever if the path was correct, the binary could not be found when I tried to run it from inside vscode.

My investigation continued. I quite soon realized that it was my lacking knowledge of flatpak that made me stumble. Since my GOROOT was pointing at /usr/lib/golang (yes i normally use GVM but couldn't be bothered today) and flatpak is sandboxed it could not find the content of GOROOT.

Thus, the simple solution was (if perhaps not the best) to

1) download the Go linux binaries

2) unpacking them into $HOME/go

3) adding this to $HOME/.bash_profile

PATH=$HOME/src/go/bin:$HOME/go/bin:$PATH
export PATH
GOROOT=$HOME/go
export GOROOT
GOPATH=$HOME/src/go
export GOPATH
Enter fullscreen mode Exit fullscreen mode

4) and then adding this to my vscode settings.json

    "terminal.integrated.shellArgs.linux": ["-l"],
    "terminal.integrated.shell.linux": "/bin/bash",
    "go.gopath": "/home/dsw/src/go",
    "go.goroot": "/home/dsw/go",
    "go.inferGopath": true,
Enter fullscreen mode Exit fullscreen mode

So, call me a newb but it's solved. Would gladly hear of any alternative ways of solving it or perhaps similar flatpak-stories.

EOF!

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (3)

Collapse
 
shea profile image
Shea

The "best" way to do this is to use a BaseApp with a known version of your dependencies (known Go version, and any other tooling you might depend on), which then can be independently coupled with your vscode flatpak.

This way, you can vary your vscode version but keep your go dependencies at known (and immutable) versions.

Collapse
 
shea profile image
Shea
Collapse
 
kakhavk profile image
Kakhaber Kashmadze

It works! thanks

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay