Skip to content

Run golang code in Makefile and use all the features of bash & multiline targets support

License

Notifications You must be signed in to change notification settings

Hand-of-Doom/gomake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GO in your Makefile

Installation

Latest version
You must have go 1.19 installed

go install github.com/Hand-of-Doom/gomake@latest

How to use

Create Gomakefile in /path/to/folder
Then cd /path/to/folder and run gomake

[foo@bar sample]$ pwd
/home/foo/sample
[foo@bar sample]$ ls
Gomakefile
[foo@bar sample]$ cat Gomakefile
sample:
    echo "Hello from bash!"
    out=go {
        fmt.Println("Hello from go!")
    }
    echo "$out"
[foo@bar sample]$ gomake sample
go: creating new go.mod: module gomakegen
go: to add module requirements and sums:
	go mod tidy
./sampletarget
Hello from bash!
Hello from go!

Using golang libraries

sample:
    go {
        import "github.com/google/uuid"
        fmt.Println(uuid.NewString())
    }

Then run gomake sample

Full bash support

You can use all the features of bash since targets are bash scripts
e.g. you can use multiline targets

sample:
    echo "Hello, Gomake!"
    echo "Next line"
    echo "Next line"

How it works?

It's just Makefile preprocessor
Gomakefile builds into a Makefile so you keep using make

Problems

Is it slow?

It's definitely slower than make cause gomake builds each go statement every time
I can work on optimization but for now this is not my primary goal

Is it Makefile compatible?

No. Gomakefile targets are bash scripts
It's not compatible with Makefile
You will need to rewrite your code

About

Run golang code in Makefile and use all the features of bash & multiline targets support

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages