Categorygithub.com/oswaldoooo/go-macro
repository
0.0.0-20240711024305-513545c40f2b
Repository: https://github.com/oswaldoooo/go-macro.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

1th Go-Macro

What is Go-Macro?

go-macro is a macro diy package. You can define yourself special macro function to generate code.

Example

1. Alias macro function like below

import (
  "github.com/oswaldoooo/go-macro/token"
)
func alias(aliasname string, src token.Struct) (content string) {
	content = fmt.Sprintf("type %s %s", aliasname, src.Name)
	return
}

// use example see examples/alias/example.go

2.Enum take

import (
  "github.com/oswaldoooo/go-macro/token"
)
func enum2str(enum []token.Value) (result string) {
	result = ""
	for _, v := range enum {
		fmt.Println("const ", v.Name(), v.Type(), v.Value())
	}
	return
}

Notice

1th Beta Edition is unstable now.

install a basic go-macro

go install github.com/oswaldoooo/go-macro/cmd/go-macro