草庐IT

reference

全部标签

linux - Go Get OAuth2 在 Linux Mint 上给我奇怪的错误

尝试跟随https://jacobmartins.com/2016/02/29/getting-started-with-oauth2-in-go/当我运行gogetgolang.org/x/oauth2时,没有任何异常出现,但是当我尝试使用gorunmain.go运行代码时我在终端中得到以下信息:#google.golang.org/grpc/credentials../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:58:32:error:referencetoundefinedfieldo

函数返回后不改变指针

语言是“Go”(“Golang”)。函数initApp正在接收指向对象的指针(Go中的“struct”)。在函数内部,我创建了一个新的对象指针并初始化了对象的值。打印和调试器都表明在函数返回之前一切都很好。但是在Return之后,作为函数参数的指针具有与函数调用之前相同的空值。为什么会这样?代码在这里:https://pastebin.com/0Gww2CQC//ptr.go.packagemainimport"fmt"typeClassXstruct{NamestringAgeint}funcmain(){varobj*ClassXinitApp(obj)fmt.Println(ob

pointers - Go 中指向结构或数组值的指针如何工作?

考虑以下Go结构:typePersonstruct{NamestringAgeintCountrystring}我遇到过无数次以下用法:p:=&Person{"Adam",33,"Argentina"}但我看不出指向结构值有什么意义,我想知道它与以下内容有何不同:n:=&999//Error我的问题是:怎么可能指向一个值,即使它是一个结构或数组而不是像字符串或int这样的基本类型?奇怪的是,以下内容对我的理解没有帮助:fmt.Println(p,&p)//outputs:&{Adam33Argentina}0xc042084018为什么程序员要通过指针声明结构实例?这样做你能取得什么成

go - Golang 之旅 : Slices are like references to arrays

我正在做Go之旅,这部分是“slice就像对数组的引用”。我根本没有更改此代码,所以我很好奇为什么它会耗尽内存。 最佳答案 不应该崩溃,可能是旅游网站有一段时间出了问题......目前任何方式, 关于go-Golang之旅:Slicesarelikereferencestoarrays,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/51776854/

pointers - 调用结构函数给出 "cannot refer to unexported field or method"

我有这样的结构:typeMyStructstruct{Idstring}和函数:func(m*MyStruct)id(){//doingsomethingwithidhere}我还有一个这样的结构:typeMyStruct2struct{m*MyStruct}现在我有一个函数:funcfoo(str*MyStruct2){str.m.id()}但是我在编译时遇到错误:str.m.idundefined(cannotrefertounexportedfieldormethodmypackage.(*MyStruct)."".id如何正确调用这个函数? 最佳答案

戈兰错误: reference to undefined identifier ‘syscall.TUNSETIFF’

因此,我一直在尝试使用gccgo构建法兰绒(https://github.com/coreos/flannel)。这是我在构建时遇到的错误:$./buildBuildingflanneld...#github.com/coreos/flannel/pkg/ipgopath/src/github.com/coreos/flannel/pkg/ip/tun.go:57:37:error:referencetoundefinedidentifier‘syscall.TUNSETIFF’err=ioctl(int(tun.Fd()),syscall.TUNSETIFF,uintptr(unsa

c - 为什么我用cgo的时候报错 "undefined reference to ` add2”

目录如下:-包括测试.h-liblibmytest.so-源代码测试.gotest.go代码如下:packagemain/*#cgoCFLAGS:-I../include#cgoLDFLAGS:-L../lib-lmytest#include"Test.h"*/import"C"funcmain(){C.add2(10,10)}当我使用gobuildtest.go时,控制台报告:#command-line-arguments/tmp/go-build168903458/command-line-arguments/_obj/test.cgo2.o:在函数_cgo_9efddd4c1a4

go - undefined reference to error 仅针对某些函数

我有一个库和一个为它构建的C接口(interface)。我的程序使用versionString()编译得很好,但使用loadConfig()就不行。这怎么可能?walker.h:#ifndefWFE_C_H#defineWFE_C_H#ifdef__cplusplusextern"C"{#endifconstchar*versionString();void*loadConfig(constchar*filePath,char*errorMessageBuffer,intbufferLen);#ifdef__cplusplus}#endif#endif工作版本:packagemain/

pointers - 将类型别名的变量传递给需要指向基础类型的指针的函数

我将自定义类型别名(使用方法)定义为:typeAwsRegionstring然后我想将这种类型的变量传递给另一个遗留(不受我控制)函数,它接受指向字符串的指针(指向基础类型的指针):funcmain(){varregionAwsRegion="us-west-2"f(®ion)//HowtoproperlycastAwsRegiontypehere?}funcf(s*string){fmt.Println(*s)//justanexample}当然我不能这样做,错误消息指出:cannotuse®ion(type*AwsRegion)astype*stringinargume

gcc - 如何修复对 `nettle_sha256_digest` 的 undefined reference ?

长话短说我正在尝试构建一个使用此依赖项的go项目:https://github.com/mqu/openldap,它又在外部链接lldap和llber库,后者又使用lgnutls,而lgnutls使用lnettle,这就是我遇到的问题。gobuild生成一长串undefinedreference,并且构建失败。这是一个示例:/usr/lib/x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o):Infunction`_ctx_init':(.text+0x468):undefinedreferenceto`nettle_sha256_digest'