All Projects → mmatczuk → Go_generics

mmatczuk / Go_generics

Licence: apache-2.0
Templates, generics engine for Go

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Go generics

Pie
🍕 Enjoy a slice! A utility library for dealing with slices and maps that focuses on type safety and performance.
Stars: ✭ 788 (+458.87%)
Mutual labels:  generics
Lgenerics
Generic algorithms and data structures for Lazarus/Free Pascal
Stars: ✭ 59 (-58.16%)
Mutual labels:  generics
Promis
The easiest Future and Promises framework in Swift. No magic. No boilerplate.
Stars: ✭ 110 (-21.99%)
Mutual labels:  generics
Goderive
Code Generation for Functional Programming, Concurrency and Generics in Golang
Stars: ✭ 848 (+501.42%)
Mutual labels:  generics
Mvvm Example
iOS protocol-oriented MVVM examples
Stars: ✭ 45 (-68.09%)
Mutual labels:  generics
Swift Complex
Complex numbers in Swift
Stars: ✭ 66 (-53.19%)
Mutual labels:  generics
Generic Lens
Generically derive traversals, lenses, and prisms.
Stars: ✭ 399 (+182.98%)
Mutual labels:  generics
Envy
😠 Environmentally friendly environment variables
Stars: ✭ 132 (-6.38%)
Mutual labels:  generics
Time
🕰 Type-safe time calculations in Swift
Stars: ✭ 1,032 (+631.91%)
Mutual labels:  generics
Miniboxing Plugin
Miniboxing is a program transformation that improves the performance of Scala generics when used with primitive types. It can speed up generic collections by factors between 1.5x and 22x, while maintaining bytecode duplication to a minimum. You can easily add miniboxing to your sbt project:
Stars: ✭ 106 (-24.82%)
Mutual labels:  generics
Genericdatasource
Generic Data Source in Swift.
Stars: ✭ 33 (-76.6%)
Mutual labels:  generics
One Liner
Constraint-based generics
Stars: ✭ 41 (-70.92%)
Mutual labels:  generics
Gen
Type-driven code generation for Go
Stars: ✭ 1,246 (+783.69%)
Mutual labels:  generics
Time
Type-safe time calculations in Kotlin, powered by generics.
Stars: ✭ 939 (+565.96%)
Mutual labels:  generics
Ply
Painless polymorphism
Stars: ✭ 117 (-17.02%)
Mutual labels:  generics
Flix
iOS reusable form library in Swift.
Stars: ✭ 725 (+414.18%)
Mutual labels:  generics
Gena
Generic pseudo-templated containers for C. Written entirely in C89 with design inspired by the C++ STL. /// DOCS ARE SLIGHTLY OUTDATED, PROJECT IS STABLE AND STILL IN ACTIVE DEVELOPMENT
Stars: ✭ 61 (-56.74%)
Mutual labels:  generics
Gomacro
Interactive Go interpreter and debugger with REPL, Eval, generics and Lisp-like macros
Stars: ✭ 1,784 (+1165.25%)
Mutual labels:  generics
Go Generics Example
Example code for Go generics
Stars: ✭ 121 (-14.18%)
Mutual labels:  generics
Goreuse
Generic Code for Go
Stars: ✭ 93 (-34.04%)
Mutual labels:  generics

Generics Build Status

This project is bazel-free version of Google go_generics tool released with gVisor project.

It allows for generating code from template while still working with standard Go code. A great example of using it is ScyllaDB go-set package.

Installation

go get -u github.com/mmatczuk/go_generics/cmd/go_generics
go get -u github.com/mmatczuk/go_generics/cmd/go_merge

go_generics

go_generics reads a Go source file and writes a new version of that file with a few transformations applied to each. Namely:

  1. Global types can be explicitly renamed with the -t option. For example, if -t=A=B is passed in, all references to A will be replaced with references to B; a function declaration like:
func f(arg *A)

would be renamed to:

func f(arg *B)
  1. Global type definitions and their method sets will be removed when they're being renamed with -t. For example, if -t=A=B is passed in, the following definition and methods that existed in the input file wouldn't exist at all in the output file:
type A struct{}

func (*A) f() {}
  1. All global types, variables, constants and functions (not methods) are prefixed and suffixed based on the option -prefix and -suffix arguments. For example, if -suffix=A is passed in, the following globals:
func f()
type t struct{}

would be renamed to:

func fA()
type tA struct{}

Some special tags are also modified. For example:

"state:.(t)"

would become:

"state:.(tA)"
  1. The package is renamed to the value via the -p argument.

  2. Value of constants can be modified with -c argument. Note that not just the top-level declarations are renamed, all references to them are also properly renamed as well, taking into account visibility rules and shadowing. For example, if -suffix=A is passed in, the following:

var b = 100

func f() {

    g(b)
    b := 0
    g(b)

}

Would be replaced with:

var bA = 100

func f() {

    g(bA)
    b := 0
    g(b)

}

Note that the second call to g() kept "b" as an argument because it refers to the local variable "b".

Unfortunately, go_generics does not handle anonymous fields with renamed types.

go_merge

go_merge merges multiple Go files into one, may be used in a pipeline before go_generics.

License

This project is distributed under the Apache 2.0 license. See the LICENSE file for details. It contains software from:

GitHub star is always appreciated!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].