#! /bin/sh
CUR_PATH=`pwd`
sudo rm -rf /usr/local/go/src/github.com/*
sudo cp -r prod-src/core/netdiagnosticsagent/goAgent/gopackages/github/* /usr/local/go/src/github.com/
sudo cp -r prod-src/core/netdiagnosticsagent/goAgent/gopackages/go.mongodb.org /usr/local/go/src/
sudo cp -r prod-src/core/netdiagnosticsagent/goAgent/cavgoutility /usr/local/go/src/
sudo cp prod-src/core/netdiagnosticsagent/goAgent/libcavwrapperlib/cavPlugin.go /root/go/src
sudo cp prod-src/core/netdiagnosticsagent/commonlib/nd_sdk.h /root/go/src
cd prod-src/core/netdiagnosticsagent/commonlib/
make sdk_go CFLAG="-g -fPIC -Iaprlib/apr-1/ -I ./lwslib/include/ -DND_GOAGENT"
sudo cp obj/libndsdk_go.so /usr/lib
cd /root/go/src
sudo rm -rf ../pkg/linux_amd64_dynlink/
sudo rm -rf /usr/local/go/pkg/linux_amd64_dynlink/
 
go install -linkshared -buildmode=shared github.com/gin-gonic/gin/ github.com/go-chi/chi github.com/gocql/gocql/ 
	github.com/gorilla/mux/ github.com/go-sql-driver/mysql/ github.com/labstack/echo/ github.com/go-pg/pg github.com/valyala/fasthttp
go install -linkshared -buildmode=shared github.com/urfave/negroni/ github.com/julienschmidt/httprouter/ 
go.mongodb.org/mongo-driver/bson/ go.mongodb.org/mongo-driver/event/ go.mongodb.org/mongo-driver/mongo/options github.com/gofiber/fiber/ google.golang.org/grpc
go build -linkshared -buildmode=plugin -o libcavwrapperlib.so cavPlugin.go

cd $CUR_PATH
sudo rm prod-src/core/netdiagnosticsagent/goAgent/go/lib/libgithub*
sudo rm prod-src/core/netdiagnosticsagent/goAgent/go/lib/libcavwrapperlib*
sudo cp /usr/local/go/pkg/linux_amd64_dynlink/libgithub.com-* prod-src/core/netdiagnosticsagent/goAgent/go/lib
sudo cp /root/go/src/libcavwrapperlib.so prod-src/core/netdiagnosticsagent/goAgent/go/lib
git commit -m "B-None |A-Dev1|R-Rev1 K|M-create go library" goAgent
git push

