set -e
-if [ ! -f env.bash ]; then
+if [ ! -f run.bash ]; then
echo 'clean.bash must be run from $GOROOT/src' 1>&2
exit 1
fi
-. ./env.bash
-if [ ! -f Make.inc ] ; then
- GOROOT_FINAL=${GOROOT_FINAL:-$GOROOT}
- sed 's!@@GOROOT@@!'"$GOROOT_FINAL"'!' Make.inc.in >Make.inc
-fi
+export GOROOT="$(cd .. && pwd)"
-if [ "$1" != "--nopkg" ]; then
- rm -rf "$GOROOT"/pkg/${GOOS}_$GOARCH
+gobin="${GOROOT}"/bin
+if ! "$gobin"/go help >/dev/null 2>&1; then
+ echo 'cannot find go command; nothing to clean' >&2
+ exit 1
fi
-rm -f "$GOROOT"/lib/*.a
-for i in lib9 libbio libmach cmd
-do
- # Do not use gomake here. It may not be available.
- $MAKE -C "$GOROOT/src/$i" clean
-done
-if [ -x "$GOBIN/go" ]; then
- go clean std || true # go command might not know about clean
-
- # TODO: Make clean work in directories outside $GOPATH
- true || go clean \
- ../misc/cgo/gmp ../misc/cgo/stdio \
- ../misc/cgo/life ../misc/cgo/test \
- ../misc/dashboard/builder ../misc/goplay\
- ../doc/codelab/wiki\
- ../test/bench/shootout ../test/bench/garbage ../test/bench/go1
-fi
+"$gobin/go" clean -i std
+"$gobin/go" tool dist clean
+"$gobin/go" clean -i cmd