The plugin I want to develop is extremely simple, which is to Base64 encode or decrypt the user's selected content.
The technical part of the main is the Go Language program development and EditPlus plug-in configuration parts, first we look at the code of the Go language, the following:
Package Main
Import (
"Encoding/base64"
"FMT"
"OS"
)
Const (
Version string = "1.0"
)
Func Main () {
Num: = Len (OS. Args)
If num < 2 | | num > 3 {
Fmt. PRINTLN ("Please use-h to see how to use the software, go Language Technology QQ Group: 195112\n")
Return
}
Switch OS. Args[1] {
Case "-A"://encode
Data: = []byte (OS. ARGS[2])
Out: = base64. Stdencoding.encodetostring (data)
Fmt. Print (out)
Case "-X"://decode
Out, err: = base64. Stdencoding.decodestring (OS. ARGS[2])
If err! = Nil {
Fmt. Println ("")
Return
}
Fmt. Printf ("%s", out)
Case "-V":
Fmt. Println ("ver:", version)
Return
Case "-H"://decode
Fmt. Println ("\ n said:")
Fmt. PRINTLN ("This program is made by Seven (Http://7di.net), which is used to base64 Add/decrypt the content.")
Fmt. Println ("\ n parameters:")
Fmt. Println ("-A to content encryption")
Fmt. Println ("-X-to-content decryption")
Fmt. Println ("-V software Version")
Fmt. Println ("-H use Help")
Fmt. Println ("\ n usage:")
Fmt. PRINTLN ("Encryption: Base64.exe-a to Encrypt")
Fmt. Println ("Decryption: Base64.exe-x to Decrypt")
Fmt. Println ("\ n AC:")
Fmt. Println ("Go Language Technology QQ Group: 195112")
Return
Default
Fmt. PRINTLN ("Please use-h to see how to use the software, go Language Technology QQ Group: 195112\n")
Return
}
}
The principle is to execute the compiled EXE file at the same time pass three parameters come in, and then with the OS. Args receive, after receiving to determine the number of parameters, we allow the passing of one or two parameters in, if less than two or more than three parameters is an error
Two parameters are to cope with-H view use Help or-V to display the version number, and three parameters to handle the encryption or decryption work.
We save the above code into a. Go file, then compile it into an. exe file, and finally change the Mail.exe to Base64.exe, and copy the Base64.exe to the EditPlus STX directory, and configure the EditPlus accordingly:
I hope this is a useful feature that can help you develop plugins.
Go Language Technology QQ Group: 195112
Develop EditPlus Editor plugin with Go language (with source code)