Develop EditPlus Editor plugin with Go language (with source code)

Source: Internet
Author: User
Tags base64 base64 encode decrypt

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.