Skip to content

jclohmann/mapgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MapGen

This package generates map-, filter and each-methods for slices.

##Building

go get github.com/jclohmann/mapgen
go install github.com/jclohmann/mapgen/...

##Usage Add a comment of the following format to your source-file:

package test

// +mapgen type=Car
type Car struct {
	brand string
	color string
}

Call the mapgen-executable:

mapgen -source car.go

Use the generated methods in your code:

var cars CarSlice
cars = append(cars, Car{"BMW", "red"})
cars = append(cars, Car{"VW", "green"})

brands := cars.Map(func(car Car) interface{} {
	return car.brand
})

Todo

  • go generate-Integration

About

This package generates map-, filter and each-methods for slices.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages