go-macro

module
v0.0.0-...-513545c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2024 License: Apache-2.0

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

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL