Skip to content

Commit

Permalink
feat(main.go): use embed instead of statik
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryooooooga authored and relastle committed Apr 5, 2022
1 parent b830280 commit 07958c3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 37 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
.PHONY: main
main: statik
main: script
go mod tidy
go build
go install

statik: ./shell/pmy.zsh
.PHONY: script
script: ./shell/pmy.zsh
# Remove comments from zsh source code
sed '/^[[:blank:]]*#/d;s/#.*//' ./shell/pmy.zsh > ./_shell/_pmy.zsh
# Make statik files
statik -src=./_shell

.PHONY: bench
bench:
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.18
require (
github.com/fatih/color v1.7.0
github.com/mattn/go-zglob v0.0.1
github.com/rakyll/statik v0.1.6
github.com/urfave/cli/v2 v2.1.0
gopkg.in/yaml.v2 v2.2.7
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ github.com/mattn/go-zglob v0.0.1 h1:xsEx/XUoVlI6yXjqBK062zYhRTZltCNmYPx6v+8DNaY=
github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
Expand Down
21 changes: 5 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package main

import (
_ "embed"
"fmt"
"io/ioutil"
"log"
"os"
"time"

"github.com/rakyll/statik/fs"
_ "github.com/relastle/pmy/statik"
"github.com/urfave/cli/v2"

pmy "github.com/relastle/pmy/src"
Expand All @@ -19,6 +17,9 @@ var (
bufferRight string
)

//go:embed _shell/_pmy.zsh
var initScript string

func mainRoutine() {
outString := pmy.Run(
pmy.Input{
Expand All @@ -30,19 +31,7 @@ func mainRoutine() {
}

func initCmdRoutine() {
statikFS, err := fs.New()
if err != nil {
log.Fatal(err)
}
f, err := statikFS.Open("/_pmy.zsh")
if err != nil {
log.Fatal(err)
}
bs, err := ioutil.ReadAll(f)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s", string(bs))
fmt.Printf("%s", initScript)
}

func ruleListCmdRoutine() {
Expand Down
14 changes: 0 additions & 14 deletions statik/statik.go

This file was deleted.

0 comments on commit 07958c3

Please sign in to comment.