ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - hexdigest/gounit-vim: Vim plugin for https://github.com/hexdigest/gounit
Vim plugin for https://github.com/hexdigest/gounit - hexdigest/gounit-vim
Visit Site

GitHub - hexdigest/gounit-vim: Vim plugin for https://github.com/hexdigest/gounit

GitHub - hexdigest/gounit-vim: Vim plugin for https://github.com/hexdigest/gounit

gounit-vim

Vim plugin for gounit tool that allows you to generate Go tests easily.

Demo

demo

Installation

gounit-vim requires gounit to be available in your $PATH. Alternatively you can provide path to gounit using g:gounit_bin setting.

Plugin installation:

  • Pathogen
    git clone https://github.com/hexdigest/gounit-vim.git ~/.vim/bundle/gounit-vim
    
  • vim-plug
    Plug 'hexdigest/gounit-vim'
    
  • NeoBundle
    NeoBundle 'hexdigest/gounit-vim'
    
  • Vundle
    Plugin 'hexdigest/gounit-vim'
    
  • Vim packages (since Vim 7.4.1528)
    git clone https://github.com/hexdigest/gounit-vim.git ~/.vim/pack/plugins/start/gounit-vim
    

You will also need to install all the necessary GoUnit binaries. It is easy to install by providing a command :GoUnitInstallBinaries, which will go get all the required binaries.

Usage

Call :GoUnit to generate test for the function declaration in the current line or all functions selected in visual mode. GoUnit also understands "range" parameters:

:5,10GoUnit     " genereate tests for functions from line 5 to line 10
:.,$GoUnit      " from the current line till the end of the file
:0,.GoUnit      " from the first line to the current line
:%GoUnit        " generate tests for the whole file

These commands generate tests using template that you set as a preferred with the :GoUnitTemplateUse <template> command. If you don't want to change your preferred template you can use all of the above commands followed by the name of the template, i.e. :GoUnit minimock If you have wildmenu option enabled you can pick desired template from the list of all registered templates with :GoUnit <TAB>.

Managing templates

There are few commands to manage your test templates:

:GoUnitTemplateAdd             " register contents of the current buffer as a new templates
:GoUnitTemplateAdd /file/name  " register /file/name as new template
:GoUnitTemplateDel template    " remove template
:GoUnitTemplateList            " display all registered test templates
:GoUnitTemplateUse template    " set template as preferred

Also you can create useful maps to use it with vim-go plugin for fast test generation.

" maps your leader key + gt to generate tests for the function under your cursor
nnoremap <leader>gt :normal vaf<cr>:GoUnit<cr>

Settings

If you want you can set path to your gounit binary if it's not in your path, for example:

let g:gounit_bin = '/home/user/go/bin/gounit'

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory