impl

package module
v0.0.0-...-10312a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2019 License: MIT Imports: 15 Imported by: 0

README

impl generates method stubs for implementing an interface.

go get -u github.com/josharian/impl

Sample usage:

$ 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")
}

You can use impl from Vim with vim-go-impl

Documentation

Overview

Package impl generates method stubs for implementing an interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stub

func Stub(recv, iface, srcDir string) string

Stub generates a stub using the receiver function to implement the provided interface

Types

type Func

type Func struct {
	Name   string
	Params []Param
	Res    []Param
}

Func represents a function signature.

type Method

type Method struct {
	Recv string
	Func
}

Method represents a method signature.

type Param

type Param struct {
	Name string
	Type string
}

Param represents a parameter in a function or method signature.

type Pkg

type Pkg struct {
	*build.Package
	*token.FileSet
}

Pkg is a parsed build.Package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL