Sublime is a lightweight text editor with a powerful plug-in system that can meet the development needs of various programming languages.
Golang is an emerging high-performance programming language that has become one of the mainstream languages in the fields of cloud computing and big data.
In this article, we will introduce how to install Golang in Sublime to facilitate your development practice.
1. Install Sublime
First, download the installation package suitable for your operating system version from the Sublime official website, and then install it according to the prompts.
2. Install the Go language package
There are two steps to install the Go language package:
1. Download the Go language development package
on the Golang official website , download the development package suitable for your operating system version. After the download is completed, you can install it according to the installation method of the operating system.
2. Set environment variables
Setting environment variables allows the computer to find the installation directory of the Go language and then use the Go language.
In Windows systems, you can follow the steps below:
(1) Click "System and Security" in the Control Panel, and then click "System".
(2) Click "Advanced System Settings" and then click "Environment Variables".
(3) In "System Variables" (or "User Variables"), find the "Path" variable and click "Edit".
(4) In the pop-up "Edit Environment Variables" window, add the Go language installation directory to the variable value list.
(5) After the setting is completed, you need to reopen the Sublime software to take effect.
In Mac system, you can follow the following steps:
(1) Open Terminal.
(2) Enter the following command:
echo 'export GOROOT=/usr/local/go' >> ~/.bash_profile echo 'export GOPATH=$HOME/Go' >> ~/.bash_profile echo 'export PATH=$PATH:$GOROOT/bin' >> ~/.bash_profile
Among them, /usr/local/go represents the installation directory of the Go language.
(3) Enter the following command to make the settings take effect:
source ~/.bash_profile
(4) After the settings are completed, reopen the Sublime software to take effect.
3. Install the Sublime plug-in
In Sublime, you can use plug-ins such as GoSublime and Go compiler to support the development of Golang. Here we take GoSublime as an example.
1. Install Package Control
Package Control is Sublime’s own plug-in management tool, which can easily install, uninstall and manage plug-ins.
In Sublime, press "ctrl " (or "cmd "), open the console, then paste the following code and press Enter:
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
2. Installation GoSublime
In Sublime, press "ctrl shift p" (or "cmd shift p"), open the command panel, enter "install package" and press Enter, then enter "GoSublime" and press Enter.
After the installation is complete, you can use the Go language for development in Sublime.
4. Writing a Hello World program
In the previous steps, we have completed the installation and configuration of Sublime and Golang. Now let us write a simple Hello World program.
1. Create a new file
In Sublime, press "ctrl n" (or "cmd n") to create a new file.
2. Enter the program code
Enter the following code:
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
Code description:
This program uses the fmt package (that is, the formatting of the standard library Input and output library), and use the Println method to output a line of text "Hello, world!" to the console.
3. Save the file
In Sublime, press "ctrl s" (or "cmd s") to save the file and save the file to the working directory you set. .
4. Run the program
Open the command line terminal, switch to the directory where the program is located, and then enter the following command:
go run hello.go
The program will output "Hello, world" on the console !"Information.
At this point, we have successfully installed, configured and used Golang and Sublime. I hope this article is helpful to you. For more tutorials about Sublime and Golang, please stay tuned for subsequent articles.
The above is the detailed content of How to install golang in sublime. For more information, please follow other related articles on the PHP Chinese website!
Sublime Text vs. VS Code: Pricing and LicensingApr 18, 2025 am 12:02 AMSublimeText is available for purchase for one time, priced at $70, and is permanently used with a PC; VSCode is free to use, and there is no license fee, but extensions and themes may be charged. When choosing, use requirements and budgets should be considered.
How to run sublimeApr 16, 2025 am 09:39 AMTo run Sublime Text, you need to download, install the application, purchase a license (optional), and then launch the application. Create or open a file to start encoding.
How to Chinese sublimeApr 16, 2025 am 09:36 AMSublime Text can be Chineseized through the following steps: 1. Download the Chinese package; 2. Install the Chinese package; 3. Restart Sublime Text; 4. Set the default language (optional); 5. Verify the Chinese version.
How to delete sublime plug-inApr 16, 2025 am 09:33 AMThere are two ways to delete plugins in Sublime Text: Delete through the Plug-in Manager: Select the plug-in you want to delete and right-click and select "Delete". Manually Delete: Navigate to the user data directory, locate the plugin folder and drag it to the Recycle Bin or Trash.
How to write code with gbk in sublimeApr 16, 2025 am 09:30 AMTo write code using GBK encoding in Sublime Text, you need to: 1. Set the project encoding to GBK; 2. Create a new file; 3. Select GBK encoding when saving as; 4. Enter the code using GBK encoding.
How to change sublime to ChineseApr 16, 2025 am 09:27 AMsublime can be translated into Chinese as: 1. Sublime, sacred; 2. Extreme, extraordinary; 3. Indescribable, awesome; 4. Sublime thought.
How to get the registration code for sublimeApr 16, 2025 am 09:24 AMThe steps to purchase a Sublime Text registration code are as follows: Visit the website and select "Buy". Select the license type and enter information. Pay and receive emails containing registration codes. Open Sublime Text, go to the License menu and paste the registration code. Click Register to activate your registration code and advanced features.
How to save the code in sublimeApr 16, 2025 am 09:21 AMSublime Text provides a variety of ways to save code, including shortcut keys (Ctrl S), menu bar (File > Save), toolbar (disk icon), and command panel (Ctrl P). In addition, it also provides an automatic save function, which can automatically save open files regularly.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment






