https://github.com/quasilyte/go-unexport
Unexport symbols from a package under a workspace automatically.
https://github.com/quasilyte/go-unexport
dev-tools go golang source-code-analysis tool
Last synced: 27 days ago
JSON representation
Unexport symbols from a package under a workspace automatically.
- Host: GitHub
- URL: https://github.com/quasilyte/go-unexport
- Owner: quasilyte
- License: mit
- Created: 2018-12-30T17:43:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-08T16:12:20.000Z (over 5 years ago)
- Last Synced: 2025-02-14T00:44:01.186Z (3 months ago)
- Topics: dev-tools, go, golang, source-code-analysis, tool
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-unexport
[](https://goreportcard.com/report/github.com/quasilyte/go-unexport)
# Overview
Tries to unexport as much symbols as possible for a given package under a current workspace.
It's mostly intended for `internal/` packages where it's simpler to change API and all your
clients are most likely reside in the same repository. In other words, it's useful for big
monoliths or command-line apps with a lot of code (which can include legacy).This tool automatically does unexporting, the only thing you should do is to review the diff
and commit it, if it makes sense. If you would like to keep some symbols exported even though
they are only used inside the package itself, one can specify `skip` flag.# Installation and usage (quick start)
This install `go-unexport` binary under your `$GOPATH/bin`:
```bash
go get github.com/quasilyte/go-unexport
```If `$GOPATH/bin` is under your system `$PATH`, `go-unexport` command should be available after that.
This should print the help message:```bash
go-unexport --help
```To run unexporting process, do:
```bash
go-unexport -v package/import/path
```Flag `-v` turns on verbose mode.
# Implementation notice
This tool does zero analysis on its own. I've used `go-rename` to do all the heavy lifting.
**Pros:**
* If you trust `go-rename`, you can trust `go-unexport`. It's unlikely that it will break your program.
* Maintainance cost is almost close to zero.**Cons:**
* The execution time is slow.# Motivation
Keep the number of exported symbols low.
It's hard to maintain minimal exported symbol set for a big projects, so this tool can help a little bit in that regard.