英文:
gocql package golang two file version in same install
问题
你在运行一个Go文件时遇到了错误:
clusterCfg.ConnectTimeout undefined (type *gocql.ClusterConfig has no field or method ConnectTimeout)
你提到在Go 1.7的文档中查看了ClusterConfig,并发现它确实有一个ConnectTimeout字段(Go版本为1.7)。
另外,你在go path的github.com目录下找到了一个gocql目录。在这个目录中,有一个cluster.go文件,其中定义了一个ClusterConfig结构体,但它没有ConnectTimeout字段,只有一个Timeout字段。
你还提供了一些关于你的Go环境的信息,以及gocql包的导入和依赖信息。
关于你的问题,可能是你的代码中使用了不匹配的版本或者导入了错误的包。你可以尝试以下解决方法:
-
确保你的代码中导入的是正确的gocql包。检查你的import语句,确保导入的路径是正确的。
-
检查你的代码中是否有其他地方定义了ClusterConfig结构体,并且该结构体没有ConnectTimeout字段。如果有,可能会导致冲突。你可以尝试在代码中搜索ClusterConfig,看看是否有其他定义。
-
确保你的代码中使用的是正确的版本。检查你的Go版本和gocql包的版本是否兼容。如果不兼容,可能会导致字段不匹配的错误。
希望这些解决方法能帮助你解决问题!如果还有其他问题,请随时提问。
英文:
getting this error when trying to run a go file (which should run)
clusterCfg.ConnectTimeout undefined (type *gocql.ClusterConfig has no field
or method ConnectTimeout)
- When I look at the documentation of go 1.7 I find that ClusterConfig does have a field ConnectTimeout. (go version = 1.7).
- If I go to the github.com directory in my go path I find a directory gocql. In this directory I find a file cluster.go which contains a definition for a struct ClusterConfig which does not have ConnectTimeout only a field Timeout.
go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/developer/gocode"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-
map=/tmp/go-build098468995=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
{
"Dir": "/home/developer/gocode/src/github.com/gocql/gocql",
"ImportPath": "github.com/gocql/gocql",
"Name": "gocql",
"Doc": "Package gocql implements a fast and robust Cassandra driver
for the Go programming language.",
"Target":
"/home/developer/gocode/pkg/linux_amd64/github.com/gocql/gocql.a",
"Root": "/home/developer/gocode",
"GoFiles": [
"address_translators.go",
"cluster.go",
"compressor.go",
"conn.go",
"connectionpool.go",
"control.go",
"debug_off.go",
"doc.go",
"errors.go",
"events.go",
"filters.go",
"frame.go",
"helpers.go",
"host_source.go",
"marshal.go",
"metadata.go",
"policies.go",
"prepared_cache.go",
"query_executor.go",
"ring.go",
"session.go",
"token.go",
"topology.go",
"uuid.go"
],
"IgnoredGoFiles": [
"batch_test.go",
"cass1batch_test.go",
"cassandra_test.go",
"compressor_test.go",
"conn_test.go",
"debug_on.go",
"errors_test.go",
"events_ccm_test.go",
"fuzz.go",
"marshal_test.go",
"session_test.go",
"stress_test.go",
"topology_test.go",
"tuple_test.go",
"udt_test.go",
"uuid_test.go",
"wiki_test.go"
],
"Imports": [
"bufio",
"bytes",
"crypto/md5",
"crypto/rand",
"crypto/tls",
"crypto/x509",
"encoding/binary",
"encoding/hex",
"encoding/json",
"errors",
"fmt",
"github.com/gocql/gocql/internal/lru",
"github.com/gocql/gocql/internal/murmur",
"github.com/gocql/gocql/internal/streams",
"github.com/golang/snappy",
"github.com/hailocab/go-hostpool",
"golang.org/x/net/context",
"gopkg.in/inf.v0",
"io",
"io/ioutil",
"log",
"math",
"math/big",
"math/rand",
"net",
"reflect",
"regexp",
"runtime",
"sort",
"strconv",
"strings",
"sync",
"sync/atomic",
"time",
"unicode"
],
"Deps": [
"bufio",
"bytes",
"container/list",
"context",
"crypto",
"crypto/aes",
"crypto/cipher",
"crypto/des",
"crypto/dsa",
"crypto/ecdsa",
"crypto/elliptic",
"crypto/hmac",
"crypto/md5",
"crypto/rand",
"crypto/rc4",
"crypto/rsa",
"crypto/sha1",
"crypto/sha256",
"crypto/sha512",
"crypto/subtle",
"crypto/tls",
"crypto/x509",
"crypto/x509/pkix",
"encoding",
"encoding/asn1",
"encoding/base64",
"encoding/binary",
"encoding/hex",
"encoding/json",
"encoding/pem",
"errors",
"fmt",
"github.com/gocql/gocql/internal/lru",
"github.com/gocql/gocql/internal/murmur",
"github.com/gocql/gocql/internal/streams",
"github.com/golang/snappy",
"github.com/hailocab/go-hostpool",
"golang.org/x/net/context",
"gopkg.in/inf.v0",
"hash",
"hash/crc32",
"internal/nettrace",
"internal/race",
"internal/singleflight",
"internal/syscall/unix",
"io",
"io/ioutil",
"log",
"math",
"math/big",
"math/rand",
"net",
"os",
"path/filepath",
"reflect",
"regexp",
"regexp/syntax",
"runtime",
"runtime/cgo",
"runtime/internal/atomic",
"runtime/internal/sys",
"sort",
"strconv",
"strings",
"sync",
"sync/atomic",
"syscall",
"time",
"unicode",
"unicode/utf16",
"unicode/utf8",
"unsafe"
],
"TestGoFiles": [
"address_translators_test.go",
"cluster_test.go",
"common_test.go",
"control_test.go",
"events_test.go",
"filters_test.go",
"frame_test.go",
"framer_bench_test.go",
"host_source_test.go",
"metadata_test.go",
"policies_test.go",
"ring_test.go",
"session_connect_test.go",
"token_test.go"
],
"TestImports": [
"bytes",
"compress/gzip",
"flag",
"fmt",
"github.com/hailocab/go-hostpool",
"golang.org/x/net/context",
"io/ioutil",
"log",
"math/big",
"net",
"os",
"sort",
"strconv",
"strings",
"sync",
"testing",
"time"
]
}
What have I done wrong? How can I have 2 versions of the same file? How do I fix it?
答案1
得分: 0
这不是一个答案,而是一个解决方案。与其继续试图挽救虚拟机,我选择获取另一个镜像并从那里继续进行。
英文:
It is not an answer, but is a solution. Rather than continue trying to salvage the vm I merely got another image and proceeded from there.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论