Last active
July 13, 2019 07:58
-
-
Save utisam/01455868e1922d0ce73324ed3df85a4b to your computer and use it in GitHub Desktop.
credits.sh
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 | |
cd $(dirname $0) | |
render_source() { | |
local -r generator=./$(basename $1) | |
local -r package=$2 | |
local -r project_root=$3 | |
cat <<EOS | |
// Code generated by ${generator}. DO NOT EDIT. | |
// go:generate ${generator} | |
package ${package} | |
import "bytes" | |
var creditsJSON = bytes.TrimSpace([]byte(\` | |
EOS | |
gocredits -json ${project_root} | jq -c '{licenses: .Licenses | del(.[].FilePath) | map(with_entries(.key |= ascii_downcase))}' | |
echo '`))' | |
} | |
render_source $0 PACKAGE_NAME PROJECT_ROOT > credits.go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使いたいパッケージのディレクトリに
PACKAGE_NAME
やPROJECT_ROOT
適当に設定して保存。初回のみ./credits.sh
を実行。その後はgo generate
。