I am using Ubuntu 22.04 LTS.
yendtj@tacs:~/workspace/tacsnet3$ uname -a
Linux tacs 6.5.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 4 14:39:20 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
yendtj@tacs:~/workspace/tacsnet3$
yendtj@tacs:~/go/pkg/mod/github.com$ env | grep GO
GOBIN=
GOROOT=/usr/local/go
GO111MODULE=on
GOPATH=
yendtj@tacs:~/go/pkg/mod/github.com$
GOPATH is not set so it should be using the modules from go.mod.
When I go build, I get
yendtj@tacs:~/workspace/tacsnet3$ go build cmd/main/main.go
# command-line-arguments
cmd/main/main.go:12:11: undefined: curl.GlobalInit
cmd/main/main.go:12:27: undefined: curl.GLOBAL_ALL
yendtj@tacs:~/workspace/tacsnet3$
My main.go program is trivial:
package main
import (
"fmt"
curl "github.com/andelf/go-curl"
jwt "github.com/golang-jwt/jwt/v5"
)
func main() {
var err error
_ = curl.GlobalInit(curl.GLOBAL_ALL)
_, err = jwt.Parse("ccc", func(t *jwt.Token) (interface{}, error) { return nil, nil })
fmt.Printf("Fail to read ini file: %v", err)
}
my go.mod is:
module testmodulename
go 1.22
require (
github.com/andelf/go-curl v0.0.0-20200630032108-fd49ff24ed97
github.com/golang-jwt/jwt/v5 v5.2.1
)
Files appear to be in the correct place:
yendtj@tacs:~/workspace/tacsnet3$ ls -l ~/go/pkg/mod/github.com/
total 24
drwxrwxr-x 3 yendtj yendtj 4096 May 4 16:19 andelf
drwxrwxr-x 3 yendtj yendtj 4096 May 4 08:39 davecgh
drwxrwxr-x 3 yendtj yendtj 4096 May 4 08:39 go-ini
drwxrwxr-x 4 yendtj yendtj 4096 May 4 16:49 golang-jwt
drwxrwxr-x 3 yendtj yendtj 4096 May 4 08:39 pmezard
drwxrwxr-x 3 yendtj yendtj 4096 May 4 08:39 stretchr
yendtj@tacs:~/workspace/tacsnet3$ ls -l ~/go/pkg/mod/github.com/andelf/
total 4
dr-xr-xr-x 4 yendtj yendtj 4096 May 4 15:39 [email protected]
yendtj@tacs:~/workspace/tacsnet3$ ls -l ~/go/pkg/mod/github.com/andelf/[email protected]/
total 148
-r--r--r-- 1 yendtj yendtj 1609 May 4 15:54 callback.go
-r--r--r-- 1 yendtj yendtj 129 May 4 15:39 callback.h
-r--r--r-- 1 yendtj yendtj 1043 May 4 15:39 c-callback.c
-r--r--r-- 1 yendtj yendtj 22105 May 4 15:39 compat.h
-r--r--r-- 1 yendtj yendtj 26001 May 4 15:54 const_gen.go
-r--r--r-- 1 yendtj yendtj 5274 May 4 15:54 const.go
-r--r--r-- 1 yendtj yendtj 2822 May 4 15:54 core.go
-r--r--r-- 1 yendtj yendtj 646 May 4 15:55 core_test.go
-r--r--r-- 1 yendtj yendtj 15520 May 4 15:55 easy.go
-r--r--r-- 1 yendtj yendtj 1578 May 4 15:55 easy_test.go
dr-xr-xr-x 2 yendtj yendtj 4096 May 4 15:39 examples
-r--r--r-- 1 yendtj yendtj 11357 May 4 15:39 LICENSE
-r--r--r-- 1 yendtj yendtj 1170 May 4 15:55 logging.go
-r--r--r-- 1 yendtj yendtj 1683 May 4 15:55 logging_test.go
dr-xr-xr-x 2 yendtj yendtj 4096 May 4 15:39 misc
-r--r--r-- 1 yendtj yendtj 4422 May 4 15:55 multi.go
-r--r--r-- 1 yendtj yendtj 79 May 4 15:39 NOTICE
-r--r--r-- 1 yendtj yendtj 1575 May 4 15:39 README.md
-r--r--r-- 1 yendtj yendtj 1500 May 4 15:55 share.go
yendtj@tacs:~/workspace/tacsnet3$
I see the function I am calling in the curl package:
yendtj@tacs:~/go/pkg/mod/github.com$ grep GlobalInit andelf/[email protected]/*.go
andelf/[email protected]/const.go:// for GlobalInit(flag)
andelf/[email protected]/core.go:func GlobalInit(flags int) error {
yendtj@tacs:~/go/pkg/mod/github.com$
I was expecting the curl go package to be found. Note that the IDE (Intellij) set for go modules does not see any syntax errors, so it must find the curl code. In fact auto completion sees the go functions.