Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for go version 1.18+ #272

Open
hmoazzem opened this issue Aug 24, 2023 · 2 comments
Open

Add support for go version 1.18+ #272

hmoazzem opened this issue Aug 24, 2023 · 2 comments

Comments

@hmoazzem
Copy link

It might be expected because of https://github.com/hyperledger/fabric-sdk-go/blob/main/test/fixtures/config/overrides/local_entity_matchers.yaml, but I haven't figured that out yet. Faced with the same issue #265, I resolved by downgrading golang to version 1.18. Reproducible scenario that works in go v1.18, but not higher.

config.yaml

version: 1.0.0

client:
  tlsEnable: true
  organization: org1
channels:
  channel0:
    orderers:
    - orderer1.orderer
    peers:
      peer0.org1: {}
organizations:
  org1:
    mspid: Org1MSP
    cryptoPath:  /home/fabric/crypto/orgs/org1/msp
    peers:
    - peer0.org1
    certificateAuthorities:
    - ca.org1
    users:
      admin:
        cert:
          path: /home/fabric/crypto/orgs/org1/admin/msp/signcerts/cert.pem
        key:
          path: /home/fabric/crypto/orgs/org1/admin/msp/keystore/key.pem
  orderer:
      mspID: OrdererMSP
      cryptoPath: /home/fabric/crypto/orderers/msp
orderers:
  orderer1.orderer:
    url: orderer1.orderer:7050
    tlsCACerts:
      path: /home/fabric/crypto/orderers/admin/tls/ca.pem
peers:
  peer0.org1:
    url: peer0.org1:7051
    tlsCACerts:
      path: /home/fabric/crypto/orgs/org1/admin/tls/ca.pem
certificateAuthorities:
  ca.org1:
    url: https://ca.org1:7054
    caName: ca.org1
    tlsCACerts:
      path: /home/fabric/crypto/orgs/org1/admin/tls/ca.pem

main.go

package main

import (
	"fmt"

	"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
	"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
)

const (
	channelID   = "channel0"
	orgName     = "org1"
	orgAdmin    = "admin"
	chaincodeID = "samplecc"
)

func main() {
	sdk, err := fabsdk.New(config.FromFile("config.yaml"))
	if err != nil {
		fmt.Println(err)
	}
	defer sdk.Close()

	clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser(orgAdmin), fabsdk.WithOrg(orgName))
	client, err := channel.New(clientChannelContext)
	if err != nil {
		fmt.Println(err)
	}

	response, err := client.Execute(channel.Request{ChaincodeID: chaincodeID, Fcn: "YourFunction"})
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(string(response.Payload))
}
@hmoazzem hmoazzem changed the title Add support for in go version 1.18+ Add support for go version 1.18+ Aug 24, 2023
@hmoazzem
Copy link
Author

Same issue #260

@werniq
Copy link

werniq commented Oct 19, 2023

I've replaced fabric-sdk-go in vendor directory with git clone https://github.com/hyperledger/fabric-sdk-go, and issue was solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants