Skip to content
[TOOL, CLI] - Filter and examine Go type structures, interfaces and especially their transitive dependencies and relationships.
Go Makefile
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
internal Intial check-in Mar 24, 2020
.gitignore
.revive.toml Intial check-in Mar 24, 2020
.travis.yml
LICENSE Intial check-in Mar 24, 2020
Makefile
README.md Added short synopsis, closes #2 Mar 25, 2020
VERSION.go Added missing word in help text Mar 25, 2020
go.mod Intial check-in Mar 24, 2020
go.sum Intial check-in Mar 24, 2020
typex.go

README.md

Build Status Coverage Status

typex

Examine Go types and their transitive dependencies.

Installation

go get -u github.com/dtgorski/typex

Synopsis

This CLI tool filters and displays Go type structures, interfaces and their relationships across package boundaries. It prints out a type hierarchy tree with additional references to transitive dependencies vital for the filtered types.

The main motivation behind typex is to get a quick overview of structures of third-party Go packages.

CLI example output

$ typex -f Rune io/...
├── error interface {
│       Error() string
│   }
└── io
    ├── RuneReader interface {
    │       ReadRune() (r rune, size int, err error)
    │   }
    └── RuneScanner interface {
            io.RuneReader
            ReadRune() (r rune, size int, err error)
            UnreadRune() error
        }
$ typex -u -f URL net/url
└── net
    └── url
        ├── URL struct {
        │       Scheme string
        │       Opaque string
        │       User *url.Userinfo
        │       Host string
        │       Path string
        │       RawPath string
        │       ForceQuery bool
        │       RawQuery string
        │       Fragment string
        │   }
        └── Userinfo struct {
                username string
                password string
                passwordSet bool
            }
$ typex -f Render github.com/dtgorski/typex/...
├── error interface {
│       Error() string
│   }
├── github.com
│   └── dtgorski
│       └── typex
│           └── internal
│               ├── Renderer interface {
│               │       Render(w io.Writer, m internal.ViewMap) error
│               │   }
│               └── ViewMap map[string]string
└── io
    └── Writer interface {
            Write(p []byte) (n int, err error)
        }
$ typex -h

Usage: typex [options] package...
Examine Go types and their transitive dependencies.

Options:
    -f <string>
          Type name filter expression. Repeating the -f option
          is allowed, all expressions aggregate to an OR query.

          The <string> filter can be a type name, a path part
          or a regular expression. Especially in the latter
          case, <string> should be quoted or escaped correctly
          to avoid errors during shell interpolation. Filter
          expressions are case sensitive, see examples below.

          The result set will contain additional references to
          transitive dependencies vital for the filtered types.

    -t    Go tests (files suffixed _test.go) will be included
          in the result set available for a filter expression.

    -u    Unexported types (lowercase names) will be included
          in the result set available for a filter expression.

More options:
    -h    Display this usage help and exit.
    -v    Print program version and exit.

The 'package' argument denotes one or more package import path
patterns to be inspected. Patterns must be separated by space.
A pattern containing '...' specifies the active modules whose
modules paths match the pattern.

Examples:
     $ typex -u go/...
     $ typex -u -f URL net/url
     $ typex github.com/your/repository/...

This tool relies heavily on Go's package managing subsystem
and is bound to its features and environmental execution
context.

Disclaimer

The implementation and features of typex follow the YAGNI principle. There is no claim for completeness or reliability.

@dev

Try make:

$ make

 make help       Displays this list
 make clean      Removes build/test artifacts
 make build      Builds a static binary to ./bin/typex
 make debug      Starts debugger [:2345] with ./bin/typex
 make install    Compiles and installs typex in Go environment
 make test       Runs tests, reports coverage
 make tidy       Formats source files, cleans go.mod
 make sniff      Checks format and runs linter (void on success)

License

MIT - © dtg [at] lengo [dot] org

You can’t perform that action at this time.