Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-htrace
diff --git a/htrace-htraced/go/gobuild.sh b/htrace-htraced/go/gobuild.sh
index 121d55b..0c5ae54 100755
--- a/htrace-htraced/go/gobuild.sh
+++ b/htrace-htraced/go/gobuild.sh
@@ -32,6 +32,18 @@
     exit 1
 }
 
+set_rpath() {
+    WHAT=$1
+    which patchelf &> /dev/null
+    if [ $? -ne 0 ]; then
+        echo "You must install the patchelf command to set RPATH."
+    else
+        if ! patchelf --set-rpath '$ORIGIN/' "${WHAT}"; then
+            echo "patchelf failed for ${WHAT}"
+        fi
+    fi
+}
+
 ACTION=install
 if [ $# -gt 0 ]; then
     ACTION="${1}"
@@ -109,6 +121,8 @@
     # Make a symlink to web src dir so can do development in-situ out
     # of build dir. This is ugly but blame go build.
     ln -fs "../../htrace-webapp/src/main/web" "${GOBIN}/../"
+    # Set the RPATH to make bundling leveldb and snappy easier.
+    set_rpath "${GOBIN}/htraced"
     ;;
 bench)
     go test org/apache/htrace/... ${TAGS} -test.bench=. "$@"