MCPcopy Index your code
hub / github.com/bykof/go-plantuml

github.com/bykof/go-plantuml @v1.3.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.3.5 ↗ · + Follow
159 symbols 407 edges 30 files 1 documented · 1% updated 18mo agov1.3.4 · 2024-12-12★ 4123 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

go-plantuml

Build Status Go Report Card go-recipes

go-plantuml generates plantuml diagrams from go source files or directories. It supports generic fields.

Installation

go install github.com/bykof/go-plantuml@latest

Please consider that $GOPATH/bin should be on our $PATH.

Usage

Generate plantuml diagrams from go sources

Usage:
  go-plantuml [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  generate    Generate a plantuml diagram from given paths
  help        Help about any command

Flags:
  -h, --help     help for go-plantuml
  -t, --toggle   Help message for toggle

Use "go-plantuml [command] --help" for more information about a command.
Generate a plantuml diagram from given paths

Usage:
  go-plantuml generate [flags]

Flags:
  -d, --directories strings   the go source directories (default [.])
  -x, --exclude string        exclude file matching given regex expression, not used if using -f flag
  -f, --files strings         the go source files
  -h, --help                  help for generate
  -l, --left-to-right         display the UML diagram left to right (default: top to bottom)
  -o, --out string            the graphfile (default "graph.puml")
  -r, --recursive             traverse the given directories recursively

Example

For example we have to files in the directory test.

// address.go
package models

import "fmt"

var (
    EmptyVariable, AnotherEmptyVariable string
    A, B                                = "1", 2
    PackageVariable                     = "Teststreet"
    AnotherPackageVariable              = "Anotherteststreet"
)

const (
    StartingStreetNumber = 1
)

type (
    AddressLike interface {
        FullAddress(withPostalCode bool) string
    }

    Address struct {
        A, B          string
        Street        string
        City          string
        PostalCode    string
        Country       string
        CustomChannel chan string
        AnInterface   *interface{}
    }
)

func (address Address) FullAddress(withPostalCode bool) string {
    return fmt.Sprintf(
        "%s %s %d",
        PackageVariable,
        AnotherPackageVariable,
        StartingStreetNumber,
    )
}

// user.go
package models

import "github.com/bykof/go-plantuml/test/address/models"

type (
    User struct {
        FirstName      string
        LastName       string
        Age            uint8
        Address        *models.Address
        privateAddress models.Address
    }
)

func (user *User) SetFirstName(firstName string) {
    user.FirstName = firstName
}

func PackageFunction() string {
    return "Hello World"
}

Then we run go-plantuml generate or go-plantuml generate -d . -o graph.puml.

This will create a graph.puml file and check for .go files inside your current directory.

Which looks like this:

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

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 115
Method 20
Struct 13
TypeAlias 8
Interface 2
FuncType 1

Languages

Go100%

Modules by API surface

formatter/plantUml_test.go25 symbols
formatter/plantUml.go21 symbols
astParser/mappers.go13 symbols
astParser/mapper_test.go10 symbols
astParser/parser.go8 symbols
astParser/formatters.go8 symbols
astParser/formatters_test.go7 symbols
domain/package.go6 symbols
domain/field.go5 symbols
domain/class.go5 symbols
test/calculator/models/calculator.go4 symbols
test/address/models/address.go4 symbols

For agents

$ claude mcp add go-plantuml \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page