+
Skip to content

sbward/interfacer

 
 

Repository files navigation

interfacer GoDoc

Code generation tools for Go's interfaces.

Tools available in this repository:

cmd/interfacer GoDoc

Generates an interface for a named type.

Installation

~ $ go get github.com/rjeczalik/interfaces/cmd/interfacer

Usage

~ $ interfacer -help
Usage of interfacer:
  -all
        Include also unexported methods.
  -as string
        Generated interface name. (default "main.Interface")
  -for string
        Type to generate an interface for.
  -o string
        Output file. (default "-")

Example

  • generate by manually
~ $ interfacer -for os.File -as mock.File
  • generate by go generate
//go:generate interfacer -for os.File -as mock.File -o file_iface.go
~ $ go generate  ./...
  • output
// Created by interfacer; DO NOT EDIT

package mock

import (
        "os"
)

// File is an interface generated for "os".File.
type File interface {
        Chdir() error
        Chmod(os.FileMode) error
        Chown(int, int) error
        Close() error
        Fd() uintptr
        Name() string
        Read([]byte) (int, error)
        ReadAt([]byte, int64) (int, error)
        Readdir(int) ([]os.FileInfo, error)
        Readdirnames(int) ([]string, error)
        Seek(int64, int) (int64, error)
        Stat() (os.FileInfo, error)
        Sync() error
        Truncate(int64) error
        Write([]byte) (int, error)
        WriteAt([]byte, int64) (int, error)
        WriteString(string) (int, error)
}

About

Go CLI tool to generate interface types from structs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载