https://github.com/jcchavezs/porto
Tool for adding vanity import to Go code
https://github.com/jcchavezs/porto
go go-linter go-tools
Last synced: 11 months ago
JSON representation
Tool for adding vanity import to Go code
- Host: GitHub
- URL: https://github.com/jcchavezs/porto
- Owner: jcchavezs
- License: apache-2.0
- Created: 2020-10-30T14:55:03.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-02T18:41:03.000Z (almost 2 years ago)
- Last Synced: 2025-07-19T09:31:17.794Z (12 months ago)
- Topics: go, go-linter, go-tools
- Language: Go
- Homepage:
- Size: 131 KB
- Stars: 40
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Porto
Tool for adding [vanity imports](https://sagikazarmark.hu/blog/vanity-import-paths-in-go/) URI to Go files.
e.g. `package zipkin` -> `package zipkin // import "github.com/openzipkin/zipkin-go"`
## Install
```bash
go install github.com/jcchavezs/porto/cmd/porto
```
## Getting started
Run the tool and display the changes without applying them
```bash
porto path/to/library
```
If you want the changes to be applied to the files directly, run:
```bash
porto -w path/to/library
```
If you just want to list the files that porto would change vanity import, run:
```bash
porto -l path/to/library
```
## Inclusion/exclusion rules
`porto` skips autogenerated, internal, third party and vendored files by default. You can customize what files get included using some flags:
- If you want to ignore files (e.g. proto generated files), pass the `--skip-files` flag:
```bash
porto --skip-files ".*\\.pb\\.go$" path/to/library
```
- If you want to ignore directories (e.g. tooling directories), pass the `--skip-dirs` flag:
```bash
porto --skip-dirs "^tools$" path/to/library
```
- If you want to include `internal` folders and directories skipped by default:
```bash
porto --include-internal --skip-dirs-use-default=false path/to/library
```
- If you want to restrict to certain files e.g. `doc.go` you
can use:
```bash
porto --restrict-to-files "doc.go$" path/to/library
```