I have checked out and trying to build already existing open source project from the link. https://github.com/o-ran-sc/ric-plt-xapp-frame. As per project's go.mod, it is built with go v1.16 however I have go 1.18.1 installed. Now as per README file it says to use below cmd to build the executables.
GO111MODULE=on GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o example-xapp examples/example-xapp.go
but it gives error
package examples/example-xapp.go is not in GOROOT (/usr/lib/go-1.18/src/examples/example-xapp.go)
then i tried with switching off the go modules as below
GO111MODULE=off GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o example-xapp examples/example-xapp.go
but now I see below errors
cannot find package "examples/example-xapp.go" in any of:
/usr/lib/go-1.18/src/examples/example-xapp.go (from $GOROOT)
/home/ravi/go/src/examples/example-xapp.go (from $GOPATH)
I am not sure now whether I have to use go module or not and how to fix this error. Futher details are given below
/home/ravi/oran/xapp-frame>go version
go version go1.18.1 linux/amd64
/home/ravi/oran/xapp-frame>
/home/ravi/oran/xapp-frame>go env GOPATH
/home/ravi/go
/home/ravi/oran/xapp-frame>
/home/ravi/oran/xapp-frame>go env GOROOT
/usr/lib/go-1.18
/home/ravi/oran/xapp-frame>
/home/ravi/oran/xapp-frame> cat go.mod
module gerrit.o-ran-sc.org/r/ric-plt/xapp-frame
go 1.16
require (
gerrit.o-ran-sc.org/r/com/golog v0.0.2
gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.1-0.20211223104552-f7d2cf80e85c
gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.7.0
github.com/fsnotify/fsnotify v1.4.9
github.com/go-openapi/errors v0.19.3
)
/home/ravi/oran/xapp-frame>go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ravi/.cache/go-build"
GOENV="/home/ravi/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ravi/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ravi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.18/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/ravi/oran/xapp-frame/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4109226075=/tmp/go-build -gno-record-gcc-switches"
/home/ravi/oran/xapp-frame>