gopp

module
v0.0.0-...-c90ad4d Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2014 License: MIT

README

gopp - Go Pre-Processor

Why? I honestly could not tell you.

Go has something like this built in - compiler build flags and tags. They're definitely a much more sane solution, so if at all possible, you should be using those instead of something like gopp.

Stack Overflow has more information, if you're interested in that topic.

A lot of the key ideas and inspiration was taken from bytbox's goprep project, which hasn't been updated in two years. Both projects are MIT Licensed.


If, for some strange reason, you're still interested in gopp, there are a few features (mainly modeled after the c preprocessor), which you can use:

NB! As a general rule, gopp rules are comments, prefixed with //gopp:! e.g., //gopp:ifdef DEBUG

command description
ifdef ifdef allows you to test whether or not a certain macro is defined at the time of interpretation.
ifndef ifndef is the opposite of ifdef, only stepping in if a certain macro is not defined.
else else works like an else block in a C-like programming language.
endif endif works like a closing bracket on an else block in a C-like programming language.
define define allows you to define arbitrary macros on the fly; e.g. //gopp:define DEBUG true
undef undef allows you to revoke currently-defined macros.

if and elseif are not supported: they'd make things needlessly complex, and are more work than I'd like to put in - if you want something like this, you should probably use Go's compiler flags/tags instead.

Note: Currently, defines are global - that is, they're not scoped to the file currently being processed. This may change at a later date, be warned.

gopp

This is the main library for using the preprocessor. The import path is github.com/sysr-q/gopp/gopp.

You can view the godocs if you're interested in using it.
GoDoc

gppc

gppc is a command line client that allows you to easily process Go code with gopp, in a similar vein to the unix tool, cpp.

NB! gppc is still very much in development, and as such you should be weary of anything it spits out. Values given with -D are added as is! That means if you pass -D VERSION=0.1, everywhere VERSION is found, the literal 0.1 will be subbed in (yes, a float!). This can cause hell if you're not careful.

To install: go install github.com/sysr-q/gopp/gppc, then check gppc and gppc prep --help.

Directories

Path Synopsis
gopp provides an easy to use (but somewhat illogical) preprocessor for Go.
gopp provides an easy to use (but somewhat illogical) preprocessor for Go.

Jump to

Keyboard shortcuts

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