Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bykof/go-plantuml
Generate plantuml diagrams from go source files or directories
https://github.com/bykof/go-plantuml
diagram generate go golang plantuml
Last synced: 4 days ago
JSON representation
Generate plantuml diagrams from go source files or directories
- Host: GitHub
- URL: https://github.com/bykof/go-plantuml
- Owner: bykof
- License: mit
- Created: 2020-01-21T09:41:01.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-23T17:41:34.000Z (5 months ago)
- Last Synced: 2024-12-01T06:09:18.526Z (11 days ago)
- Topics: diagram, generate, go, golang, plantuml
- Language: Go
- Homepage:
- Size: 198 KB
- Stars: 389
- Watchers: 10
- Forks: 27
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - go-plantuml - Generate Plantuml diagram based on Go source code (Open source library / Charts)
README
# go-plantuml
[![Build Status](https://github.com/bykof/go-plantuml/actions/workflows/test.yml/badge.svg)](https://github.com/bykof/go-plantuml/actions/workflows/test.yml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/bykof/go-plantuml)](https://goreportcard.com/report/github.com/bykof/go-plantuml)
[![go-recipes](https://raw.githubusercontent.com/nikolaydubina/go-recipes/main/badge.svg?raw=true)](https://github.com/nikolaydubina/go-recipes)go-plantuml generates plantuml diagrams from go source files or directories.
It supports generic fields.## Installation
```bash
go install github.com/bykof/go-plantuml@latest
```Please consider that `$GOPATH/bin` should be on our `$PATH`.
## Usage
```bash
Usage:
go-plantuml [command]Available Commands:
generate Generate a plantuml diagram from given paths
help Help about any commandFlags:
-h, --help help for go-plantuml
-t, --toggle Help message for toggleUse "go-plantuml [command] --help" for more information about a command.
```
```bash
Usage:
go-plantuml generate [flags]Flags:
-d, --directories strings the go source directories (default [.])
-f, --files strings the go source files
-h, --help help for generate
-o, --out string the graphfile (default "graph.puml")
-r, --recursive traverse the given directories recursively
-x, --exclude exclude file matching given regex expression, not used if using -f flag
```## Example
For example we have to files in the directory `test`.
```go
// address.go
package modelsimport "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,
)
}```
```go
// user.go
package modelsimport "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](https://choosealicense.com/licenses/mit/)