First, you will need to have your Go environment correctly configured. The path folder for your Go binaries must also be added to the environment variable $PATH
in your operating system. Please, find below some guidelines on how to do that in your operating system:
Then, you will need to install the impler
package as follows:
go get -u github.com/jiandahao/impler
Obs: make sure your $GOPATH/bin
is in your $PATH
so that you can access the impler
binary.
for local installation:
npm i vsce -g
// remove `out/**` in .vscodeignore
// then do
vsce package
then you will get a .vsix file:
vscode-go-impl-methods-0.0.0-development.vsix
select and install the generated vsix file.
VS Code extension that automatically generates method stubs for Golang interfaces. Just inform the receiver and the interface. The extension will generate the method stubs.
- Inform the receiver as a comment (see some examples below):
// mt MyType
// mp *MyPointer
- Open the Command Palette
Ctrl+Shift+P
(Linux and Windows)Shift+Command+P
(macOS)
- Look for Go: Implement Interface Methods
- Start typing the name of the interface and pick it from the list (ex:
io.Reader
) - Hit Enter!
VS Code extension that automatically extract interface for Golang structure. Just inform the receiver name. The extension will extract interface.
- Inform the receiver as a comment (see some examples below):
// myInterface
- Open the Command Palette
Ctrl+Shift+P
(Linux and Windows)Shift+Command+P
(macOS)
- Look for Go: Extract Interface
- Start typing the name of the interface and pick it from the list (ex:
time.Ticker
) - Hit Enter!
The extension is working, but there are a few things to improve. Any suggestions are welcomed. Please, feel free to contribute.
Enjoy!