-
-
Save ggaaooppeenngg/eb6ce76fd467e149e29eb9cebbe9df4e to your computer and use it in GitHub Desktop.
get std package names of golang
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/sh | |
# set -x | |
# set -e | |
paths=$(find $GOROOT/src -type d | sed '1d' | sed "s|$GOROOT/src/||" | grep -v "^vendor" | grep -v "^cmd" | grep -v "builtin" | tr '\n' ' ') | |
paths_contains_go_source="" | |
cd $GOROOT/src | |
for path in $paths | |
do | |
if ls $path/*.go 1> /dev/null 2>&1; then | |
paths_contains_go_source+="\t\"$path\",\n" | |
fi | |
done | |
paths_contains_go_source=$(echo $paths_contains_go_source | sed '$d') | |
echo "package main" | |
echo "" | |
echo "// This file is generated by https://gist.github.com/ggaaooppeenngg/eb6ce76fd467e149e29eb9cebbe9df4e" | |
echo "var stdPackageNames = []string{" | |
echo "$paths_contains_go_source" | |
echo "}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment