GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - reflog/struct2interface: CLI Tool to extract an Interface from a Golang struct using AST

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
main.go
main.go
 
 

Repository files navigation

struct2interface

struct2interface is a CLI utility to extract an interface from a Golang struct

Installation

go get github.com/reflog/struct2interface

Usage

struct2interface --help

Usage:
  struct2interface [flags]

Flags:
  -f, --folder string      Path to the package in which the struct resides
  -h, --help               help for struct2interface
  -i, --interface string   Name of the output interface
  -o, --output string      Path to output file (will be overwritten)
  -p, --package string     Name of the package in which the struct resides
  -s, --struct string      Name of the input struct
  -t, --template string    Path to a Go template file to use for writing the resulting interface

struct2interface -f "/home/reflog/go/src/github.com/mattermost/mattermost-server/app" -o "/home/reflog/go/src/github.com/mattermost/mattermost-server/
app/app_iface.go" -p "app" -s "App" -i "AppIface"

Other tools

Before writing this, I tried the following projects, but encountered issues:

Interfacer - incredibly slow, dumps odd messages to stderr and writes fully qualified package name instead of localized one, i.e. *github.com/mattermost/mattermost-server/v5/model.Config instead of *model.Config
Ifacemaker - created duplicate imports (in my case "html/template" and "text/template")

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

CLI Tool to extract an Interface from a Golang struct using AST

Topics

astgorefactoringstruct

Resources

Readme
MIT license
Activity

Stars

20 stars

Watchers

1 watching

Forks

3 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.