This will allow you to connect to your WSL environment from Visual Studio Code. Make sure that you have installed the Remote - WSL extension. Open Visual Studio Code as you normally would on your Windows desktop environment. Setting up Visual Studio Codeįirst, we’ll need to open Visual Studio Code so that we can edit the files in our WSL environment. Next up, we’ll set up your development environment using Visual Studio Code. # Verify that the installation was successful go versionĬongratulations! You now have Go installed on your machine. echo 'export PATH=$PATH:/usr/local/go/bin' > ~/.bashrc # If you don't use this, you'll need to run 'export PATH=$PATH:/usr/local/go/bin' # every time you start a new shell. Note the last part about > ~/.bashrc # This is important to make sure that the filepath is loaded when you start a new shell. # If you are replacing an existing version of Go, you'll need to remove the existing version first # Note that your location may be elsewhere, depending on any instructions you followed previously # or previous decisions # Also note that install multiple versions of Go by using the go install command, as documented # in the Go documentation at # sudo rm -rf /usr/local/go # Now you can move the files to the correct location sudo mv go /usr/local # Extract the files to your local directory tar -xzvf go1.18.1. # Download the latest version of go wget I’ll focus on Ubuntu 20.04 in my Windows Subsystem for Linux (WSL) setup. The installation process is fairly straightforward, and will of course be different for each operating system. For example, I had a version of Go installed on my machine from the time that I used when running some customisations setting up the powerline-go configuration for my ohmyposh setup. It may be preinstalled by your operating system, or you may have installed it manually. You can find the full list of available versions of Go for download here.Įven if you haven’t used the go command before, it’s possible that you have a version of Go installed on your machine. if there are specific language version dependencies). This is useful if you want to use different versions of Go to build different projects (e.g. Note: It is possible to install multiple versions of Go on your machine. If we’ve never used the go command before, it’s possible that you don’t have Go installed on our machine yet.įortunately, the Go developer documentation has a great installation guide. This means that you need to compile your code before you can run it. Like many other languages, Go is a compiled language. Got that configured? Great! Let’s get started! Setting up Go on your machine I personally use Ubuntu 20.04, but you can use any of the distributions that are available. You have a Linux Distribution installed.You have Windows Subsystem for Linux (WSL) installed.I’m going to make some assumptions about your environment. More on that in another post though! Pre-requisites For example, the net/http package contains code for working with HTTP requests and responses. A package is a collection of related code. Go heavily relies on the concept of packages. It’s in the top 15 most popular languages from the 2021 Stack Overflow Developer Survey. You’ll be familiar with several of the projects that it powers, including Hugo, Docker, Terraform, Kubernetes and more. Go was originally developed by Google in 2007, and is now maintained by the Go team. However, there are a few additional language functions (particularly around memory safety and garbage collection). From a language design perspective, it is very familiar to working in C. It is a great language for building web applications, but it’s also great for building command-line applications. Go (commonly referred to as golang) is a statically typed, compiled programming language. In this blog post, I’m going to walkthrough the process of setting up Go on my machine, and then the experience of using Visual Studio Code and Windows Subsystem for Linux (WSL) with Ubuntu. It’s fair to say that my development environment was ‘functional’, but I wanted to revisit it to make sure that I could get the best out of it. I’ve wanted to learn Go for a while, so I thought this could be a great opportunity to get hands on and try it out. Over the past few weeks, I have been working on a new set of pet projects. Time’s pushing on… Let’s git out of here.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |