![]() ![]() Let's break down this code to understand what's going on: When you save this file, VS Code will automatically format your code according to Go's format guidelines. Write the following code in the file: package main For now, the file has no dependencies, but that's about to change soon. This file holds your module's name, the Go version used to create it, and the external dependencies it has - with their respective versions. ![]() If you don't have a GitHub account yet, I highly recommend you create one, so you can replace the placeholders in the above command with your GitHub handle and a repo name. Open VS Code's terminal by going to View > Terminal and type in: go mod init // We want to be able to easily handle all our dependencies, so let's make use of go modules. ![]() Standard library packages can be called fmt or net/http, while the import path of other types of package is usually the repository where the package is held, such as. Packages can be imported and, by convention, a package's name is the same as the last element of the import path. Go programs are made with packages and the main package is the entry point of a Go program. There are a few ways you can create a new file, but let's keep things simple and right-click in the folder area to choose New File, like so: Creating a new file So you're probably on the VS Code screen right now. The $_ will get the arguments passed from the previous command, in this case hello-go. This will create a folder named hello-go in the current directory and open Visual Studio Code there. If you want to do this in a fancy way and familiarize yourself with the console/terminal in the process, just open your favorite terminal app and type: mkdir hello-go & code $_ What kind of course would this be if we wouldn't start with the classic "Hello World!" application?Ĭreate a folder named hello-go and open Visual Studio Code on it. Step 2: Understanding Go basics Your First Go Application
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |