add makefile
This commit is contained in:
parent
59230b7ad5
commit
6708d9ff33
3 changed files with 34 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
.DS_Store
|
||||
tmp
|
||||
indir
|
||||
indir-*
|
||||
|
|
|
|||
28
Makefile
Normal file
28
Makefile
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
GOOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||
GOARCH := $(shell uname -m)
|
||||
TRIPLE := $(GOOS)-$(GOARCH)
|
||||
|
||||
.PHONY: build
|
||||
|
||||
build:
|
||||
go build -o indir-$(TRIPLE) .
|
||||
ln -sf ./indir-$(TRIPLE) ./indir
|
||||
|
||||
build-multiplatform: indir-linux-amd64 indir-darwin-arm64
|
||||
|
||||
indir-linux-amd64:
|
||||
GOOS=linux GOARCH=amd64 go build -o ./indir-linux-amd64 .
|
||||
|
||||
indir-darwin-arm64:
|
||||
GOOS=darwin GOARCH=arm64 go build -o ./indir-darwin-arm64 .
|
||||
|
||||
clean:
|
||||
rm -rf \
|
||||
./indir \
|
||||
./indir-$(TRIPLE) \
|
||||
./indir-darwin-arm64 \
|
||||
./indir-linux-amd64
|
||||
|
||||
install: build
|
||||
cp ./indir-$(TRIPLE) /usr/local/bin/indir
|
||||
chmod +x /usr/local/bin/indir
|
||||
6
main.go
6
main.go
|
|
@ -12,8 +12,12 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed templates/dir.html
|
||||
var dirTemplateSrc string
|
||||
|
||||
type (
|
||||
Directory struct {
|
||||
Name string
|
||||
|
|
@ -89,7 +93,7 @@ func main() {
|
|||
".DS_Store",
|
||||
}
|
||||
|
||||
dirTemplate, err := template.ParseGlob("./templates/dir.html")
|
||||
dirTemplate, err := template.New("dir").Parse(dirTemplateSrc)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "fatal: failed to parse directory template: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue