Run GO language directly in Notepad++ - (via NppExec plugin)

prerequisites:

1. It is recommended to read the article [Run GO language directly in Notepad++]:  Run GO language directly in Notepad++_go language notepad_xijin's no1's blog-CSDN blog

2. It is recommended to read the article [Install the NppExec plug-in in notepad++]: Install the NppExec plug-in in notepad++_Xijin's no1 blog-CSDN blog

 

The following is the text

1. Open the .go file (or create a new file, write the following go code into it, and save the file as Demo.go)

package main

import "fmt"

func main() {
	// 终端输出hello world
	fmt.Println("Hello world!")
}

 

2. Press F6 to execute or plug-in->NppExec->Execute..., to configure the compiler for the first use, enter the following code:

NPP_SAVE

cmd /c gofmt -w "$(CURRENT_DIRECTORY)\$(NAME_PART).go"
cmd /c go run "$(CURRENT_DIRECTORY)\$(NAME_PART).go"

// 格式化生效需要等待一段时间

 Some command reference links (some go commands):  some go commands_Xijin's no1's Blog-CSDN Blog

 

3. Click OK, run the go code, and the console outputs the result:

4. At this point, the installation is complete. But for the convenience of use, configure the menu and shortcut keys next.

5. Click the menu Plugins->NppExec->Advanced Options...

6. Select the Place to the Macros submenu, select [Format, compile and run go (do not generate exe)] in the Associated script drop-down list box, and enter [Format, compile and run go (do not generate exe)] in the above Item name edit box ], then click the Add/Modify button in the lower left corner, then click the OK button to close the dialog box, and restart Notepad++

7. Finally, let’s associate a shortcut key with the [Format, compile and run go (do not generate exe)] command we just added. Click Settings->Shortcut Mapper...

8. In the pop-up shortcut key management (Shortcut mapper) dialog box, select the Plugin commands (Plugin commands) button, switch to the commands from the plugin, and find our [Format, compile and run go (do not generate exe)] in the list , double-click the left mouse button (or click the Modify button at the bottom of the dialog box), and edit the shortcut key in the pop-up dialog box:

The shortcut key I set for [Format, compile and run go (do not generate exe)] is ALT+M.

9. Now you can see [Format, compile and run go (do not generate exe)] under the Macro menu of Notepad++, click it or press the shortcut key to compile and run the go code directly

Guess you like

Origin blog.csdn.net/xijinno1/article/details/131486035
Recommended