Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mdempsky/unconvert
Remove unnecessary type conversions from Go source
https://github.com/mdempsky/unconvert
Last synced: about 2 months ago
JSON representation
Remove unnecessary type conversions from Go source
- Host: GitHub
- URL: https://github.com/mdempsky/unconvert
- Owner: mdempsky
- License: bsd-3-clause
- Created: 2016-02-19T21:59:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-09-07T12:55:36.000Z (10 months ago)
- Last Synced: 2024-01-31T22:13:47.080Z (5 months ago)
- Language: Go
- Homepage:
- Size: 71.3 KB
- Stars: 370
- Watchers: 12
- Forks: 24
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-code-formatters - unconvert - - removes unnecessary type conversions. (Code formatters)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-linters - unconvert - Remove unnecessary type conversions from Go source. (Linters / Style and Patterns Checking)
- awesome-go-extra - unconvert - 02-19T21:59:07Z|2022-06-16T12:45:53Z| (Code Analysis / Routers)
- awesome-go-cn - unconvert
- awesome-stars - mdempsky/unconvert - Remove unnecessary type conversions from Go source (Go)
- awesome-go-zh - unconvert
- static-analysis - unconvert
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-cn - unconvert
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-projects - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - | - | - | (Code Analysis / Routers)
- awesome-go-with-framework - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-zh - unconvert
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-cn - unconvert
- awesome-go-stars - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-Char - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go. - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-cn - unconvert - 从go语言代码中移除不必要的类型转换 (代码分析 / 路由)
- awesome-go-with-stars - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- repo-1316-awesome-go-cn - unconvert
- repo-1211-awesome-go-cn - unconvert
- awesome-reader - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- Go-awesome - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-cn - unconvert
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - 從go語言代碼中移除不必要的類型轉換 (代碼分析 / 路由)
- awesome-go-handwritten - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. - :arrow_down:0 - :star:152 (Code Analysis / Routers)
- awesome-go2 - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go-cn - unconvert
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- awesome-go - unconvert - Remove unnecessary type conversions from Go source. (Code Analysis / Routers)
- go-awesome-cn-star - unconvert
- awesome-go - unconvert - Remove unnecessary type conversions from Go source - ★ 226 (Code Analysis)
README
# About
The unconvert program analyzes Go packages to identify unnecessary
type conversions; i.e., expressions T(x) where x already has type T.# Install
go install github.com/mdempsky/unconvert@latest
# Usage
$ unconvert -v bytes fmt
GOROOT/src/bytes/reader.go:117:14: unnecessary conversion
abs = int64(r.i) + offset
^
GOROOT/src/fmt/print.go:411:21: unnecessary conversion
p.fmt.integer(int64(v), 16, unsigned, udigits)
^# Flags
Using the -v flag, unconvert will also print the source line and a
caret to indicate the unnecessary conversion's position therein.Using the -apply flag, unconvert will rewrite the Go source files
without the unnecessary type conversions.Using the -all flag, unconvert will analyze the Go packages under all
possible GOOS/GOARCH combinations, and only identify conversions that
are unnecessary in all cases.E.g., syscall.Timespec's Sec and Nsec fields are int64 under
linux/amd64 but int32 under linux/386. An int64(ts.Sec) conversion
that appears in a linux/amd64-only file will be identified as
unnecessary, but it will be preserved if it occurs in a file that's
compiled for both linux/amd64 and linux/386.