Skip to content

Instantly share code, notes, and snippets.

@ggaaooppeenngg
Last active January 24, 2017 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggaaooppeenngg/eb6ce76fd467e149e29eb9cebbe9df4e to your computer and use it in GitHub Desktop.
Save ggaaooppeenngg/eb6ce76fd467e149e29eb9cebbe9df4e to your computer and use it in GitHub Desktop.
get std package names of golang
#!/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