Created
June 25, 2021 11:55
-
-
Save ThomasJunk/fbb34693d8d1ef3fc2bd95142d5e93c5 to your computer and use it in GitHub Desktop.
Template for personal go projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
WORKDIR=${PWD##*/} | |
MAINDIR="cmd/$WORKDIR" | |
mkdir -p "$MAINDIR" | |
MAIN=$(cat <<-EOF | |
package main | |
import "fmt" | |
func main(){ | |
fmt.Println("hello world!") | |
} | |
EOF | |
) | |
MAKEFILE=$(cat <<-EOF | |
# SPDX-License-Identifier: MIT | |
# © 2021 Thomas Junk | |
GOCMD=go | |
GOBUILD=\$(GOCMD) build | |
NAME=$WORKDIR | |
PATHTOMAIN=./cmd/\$(NAME) | |
all:\tbuild | |
build: | |
\t\$(GOBUILD) -o \$(NAME) \$(PATHTOMAIN)/main.go | |
EOF | |
) | |
RUNAPP=$(cat <<-EOF | |
#!/usr/bin/env bash | |
# SPDX-License-Identifier: MIT | |
# © 2021 Thomas Junk | |
exec 2>&1 ./$WORKDIR | |
EOF | |
) | |
echo -e "$MAKEFILE" > makefile | |
echo "$RUNAPP" > run-app.sh | |
chmod u+x run-app.sh | |
echo "$MAIN" > $MAINDIR/main.go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment