This is a Go module containing various helpful tools.
Creates an alias to a Go package by generating type aliases, functions, and variables to be used in a different package:
❯ go tool aliaspkg -include As -stdout errors
// Code generated by aliaspkg. DO NOT EDIT.
package errors
import (
"errors"
)
// This is an alias of https://pkg.go.dev/errors#As.
func As(err error, target any) bool {
return errors.As(err, target)
}Often times there is functionality that I'd like to extend in other packages, such as the Go standard library. Typically, I would need to give my package a new name (that may be longer, less intuitive, etc), or wrangle with import aliases when I use both packages in a file. Instead, this tool can be used to generate a Go file that effectively re-exports the existing package within a new package. This then allows me to add new types, functions, etc to my new package that can be used seamlessly with the same import.