Go language development environment configuration (sublime Text3 + gosublime)

Time:2022-5-24
catalogue
  • 1. Sublime text 3 installation
  • 2. Install package control (plugin management of sublime)
  • 3. Install gosublime

At the beginning of the development of go language, Google developed the development tools of go on the Internet, mostly recommending sublime Text3 + gosublime. However, in practice, gosublime cannot be installed directly and needs to be installed manually. Organize your installation process.

 

1. Sublime text 3 installation

Download address: https://www.sublimetext.com/3 Or local download address

I chose the window installation package

Click to install after downloading (no more details)

After installation, it will appear on the desktopGo language development environment configuration (sublime Text3 + gosublime)Shortcut icon (if not, you can search for sublime in the start menu) and double-click to open it.

 

2. Install package control (plugin management of sublime)

Use Ctrl + ‘to turn up the console

Go language development environment configuration (sublime Text3 + gosublime)

Use the installation code on the official website to install package control

Official website address: https://packagecontrol.io/installation

Installation code:

import urllib.request,os,hashlib;
h = "6f4c264a24d933ce70df5dedcf1dcaee" + "ebe013ee18cced0ef93d5f746d80ef60";
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)

Press enter to confirm the installation

Go language development environment configuration (sublime Text3 + gosublime)

After running, package control will appear under preferences

Go language development environment configuration (sublime Text3 + gosublime)

Use Ctrl + Shift + P to activate package control

Go language development environment configuration (sublime Text3 + gosublime)

Enter install and selectinstall Packageenter

Go language development environment configuration (sublime Text3 + gosublime)

After running, the window for installing plug-ins will be called

Go language development environment configuration (sublime Text3 + gosublime)

Search for the plug-in you want, and select enter to install it automatically.

 

3. Install gosublime

Online tutorials are installed automatically by inputting gosublime directly, but the reality is cruel.

Go language development environment configuration (sublime Text3 + gosublime)

The installer didn’t find gosublime, through a call to Google. Found that the current branch of gosublime does not support automatic installation

The official website information is as follows: https://packagecontrol.io/packages/GoSublime

Go language development environment configuration (sublime Text3 + gosublime)

At the same time, the official website provides installable methods:

See https://margo.sh/b/migrate/ for instructions on how to switch to the active development branch.

Click the link and you will find that you are currently using the development branch.

The installation steps are as follows:

Go language development environment configuration (sublime Text3 + gosublime)

Google Translation:

Go language development environment configuration (sublime Text3 + gosublime)

According to the installation document, you need to manually download the code of gosublime to the package directory of sublime. (GIT needs to be installed)

Enter the package directory of sublime, and you can quickly jump through the menu preferences = “browse package”

Go language development environment configuration (sublime Text3 + gosublime)

Go language development environment configuration (sublime Text3 + gosublime)

Use git Bash and CD to the package directory

Go language development environment configuration (sublime Text3 + gosublime)

Run git clone https://margo.sh/GoSublime , download the code to the package directory

After downloading, sublime will automatically detect the plug-in and install it. If the go locale is not installed, an error will be reported

Go language development environment configuration (sublime Text3 + gosublime)

Go environment installation can refer to: https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/01.0.md

Display after correct installation:

Go language development environment configuration (sublime Text3 + gosublime)

At this time, the plug-in has been installed. Next, you need to configure the plug-in.

Use ‘Ctrl ++ X ‘(hold down Ctrl and press. X in sequence) to open the Margo configuration file. (you can press enter to save without modification) after saving, sublime will automatically apply the configuration.

Go language development environment configuration (sublime Text3 + gosublime)

Then use ‘Ctrl +.’ Turn on the gosublime controller, select default settings, and press enter

Go language development environment configuration (sublime Text3 + gosublime)

The configuration file of gosublime will be opened and

"gscomplete_enabled": false,
// Whether or not gsfmt is enabled
"fmt_enabled": false,

Change to

"gscomplete_enabled": true,
 // Whether or not gsfmt is enabled
"fmt_enabled": true,

Go language development environment configuration (sublime Text3 + gosublime)

Save the file.

Now create a main Go start coding the go language.

You will find the code now

Go language development environment configuration (sublime Text3 + gosublime)

Go language development environment configuration (sublime Text3 + gosublime)

And when saving the file, the code will be automatically formatted (call go FMT).

Now that our editor has been configured, it supports code completion, code highlighting, error prompt, code formatting and other functions

This is the end of this article about go language development environment configuration (sublime Text3 + gosublime). For more information about go language development environment configuration, please search the previous articles of developepper or continue to browse the relevant articles below. I hope you will support developepper in the future!