1
이동 프로젝트에서 두 개의 프로젝트를 판매했습니다. 그리고 성공적으로 프로젝트를 컴파일했습니다. 프로젝트를 실행했을 때 오류 "panic: http: multiple registrations for /debug/requests"
이보고되었습니다. 자세한 오류는 다음과 같습니다.공황 상태 : http :/debug/requests에 대한 복수 등록
goroutine 1 [running]:
net/http.(*ServeMux).Handle(0x19ae000, 0x126bb20, 0xf, 0x1964540, 0x1297d90)
/usr/local/go/src/net/http/server.go:2270 +0x627
net/http.(*ServeMux).HandleFunc(0x19ae000, 0x126bb20, 0xf, 0x1297d90)
/usr/local/go/src/net/http/server.go:2302 +0x55
net/http.HandleFunc(0x126bb20, 0xf, 0x1297d90)
/usr/local/go/src/net/http/server.go:2314 +0x4b
github.own.com/chalex/testfabric/vendor/github.com/hyperledger/fabric-sdk-go/vendor/golang.org/x/net/trace.init.0()
/home/chalex/ibm/src/github.own.com/chalex/testfabric/vendor/github.com/hyperledger/fabric-sdk-go/vendor/golang.org/x/net/trace/trace.go:115 +0x42
github.own.com/chalex/testfabric/vendor/github.com/hyperledger/fabric-sdk-go/vendor/golang.org/x/net/trace.init()
<autogenerated>:1 +0x1cd
github.own.com/chalex/testfabric/vendor/github.com/hyperledger/fabric-sdk-go/vendor/google.golang.org/grpc.init()
<autogenerated>:1 +0x82
github.own.com/chalex/testfabric/vendor/github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer.init()
<autogenerated>:1 +0x6f
github.own.com/chalex/testfabric/vendor/github.com/hyperledger/fabric-sdk-go/api/apitxn.init()
<autogenerated>:1 +0x44
github.own.com/chalex/testfabric/chaincode/client.init()
<autogenerated>:1 +0x49
main.init()
누구나 수정 방법에 대해 알고 있나요? 내가 가져온 두 프로젝트 모두/debug/reruests에서 듣기 때문이죠?
당신의 추측은 맞습니다. 코드를 변경해야합니다. – Volker
이것이 라이브러리가'init' 함수에서 이런 종류의 일을하는 것은 위험합니다. 핸들러는 명시 적으로 핸들러를 등록 할 때만 등록해야합니다. – Adrian
감사합니다. @Volker @ 애드리안. 이유를 찾았습니다. 그것은'golang.org/x/net/trace' 프로젝트 때문입니다. init() 함수에서 하드 코드로'debug/request'를 처리합니다. 따라서 두 프로젝트가 모두 해당 라이브러리를 가져 오는 경우 충돌이 발생합니다. – Chalex