impl, impl生成用于实现接口的方法存根

分享于 

2分钟阅读

GitHub

  繁體 雙語
impl generates method stubs for implementing an interface.
  • 源代码名称:impl
  • 源代码网址:http://www.github.com/josharian/impl
  • impl源代码文档
  • impl源代码下载
  • Git URL:
    git://www.github.com/josharian/impl.git
    Git Clone代码到本地:
    git clone http://www.github.com/josharian/impl
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/josharian/impl
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    

    impl 生成用于实现接口的方法存根。

    go get -u github.com/josharian/impl

    示例用法:

    $ impl 'f *File' io.ReadWriteCloser
    func (f *File) Read(p []byte) (n int, err error) {
     panic("not implemented")
    }
    func (f *File) Write(p []byte) (n int, err error) {
     panic("not implemented")
    }
    func (f *File) Close() error {
     panic("not implemented")
    }# You can also provide a full name by specifying the package path.# This helps in cases where the interface can't be guessed# just from the package name and interface name.$ impl 's *Source' golang.org/x/oauth2.TokenSource
    func (s *Source) Token() (*oauth2.Token, error) {
     panic("not implemented")
    }

    你可以使用来自Vim的implvim-go-impl。


    INT  IMP  接口  method  STUB  Stubs  
    相关文章