goland create project configuration

Original: http://c.biancheng.net/view/6170.html

 

Create project

First, find "New" in the "File" menu and select "Project" in the next menu to create a new project. 
 

New Project
Select New Project in the menu


Select a directory for the project (try to select an empty directory if possible), and click "Create" to complete the creation.
 

Create project

Edit run / debug configuration

Every time after creating a project, we need to configure some Goland, find "Add Configuration" in the upper right of Goland and click.
 

Click Add Configuration
Click Add Configuration


Click "+" in the pop-up window, and select "Go Build" in the drop-down menu.
 

Edit configuration information
Edit configuration information


After clicking "Go Build", fill in the corresponding information in the window as shown below.
 


There are a few points to note in the picture above:

  • Name: the name of this configuration information, which can be customized or can use the system default value;
  • Run kind: here needs to be set to "Directory";
  • Directory: used to set the directory where the main package is located, cannot be empty;
  • Output directory: used to set the storage directory of the executable file generated after compilation. It can be empty. When it is empty, the executable file is not generated by default;
  • Working directory: used to set the running directory of the program. It can be the same as the "Directory" setting, but it cannot be empty.

Tip: Except for the points mentioned above, the rest of the configuration items can use the system's default values ​​without modification.

Write and run code

After configuring Goland, you can write code in the project folder. First create a new Go source file, right-click on the project folder, then find "New" in the pop-up menu, and select "Go File" in the next menu, and finally enter the file name in the pop-up box (red box) ) And select “Empty file”, then press “Enter” key to confirm after making sure.
 

New Go file
New Go source file


Write the following code in the newly created Go source file.
 

Write test code
Write test code


Then, we can click on the green triangle in the upper right of Goland to run the program written above.
 

Run the program

Published 125 original articles · Like 31 · Visits 60,000+

Guess you like

Origin blog.csdn.net/Fiverya/article/details/104376180