func (c *Client) LoadUserFromStateStore(name string) (fab.User, error) {
	if name == "" {
		return nil, nil
	}
	if c.stateStore == nil {
		return nil, nil
	}
	if c.cryptoSuite == nil {
		return nil, errors.New("cryptoSuite required")
	}
	value, err := c.stateStore.Load(name)
	if err != nil {
		if err == kvstore.ErrNotFound {
			return nil, nil
		}
		return nil, err
	}
	valueBytes, ok := value.([]byte)
	if !ok {
		return nil, errors.New("state store return wrong data type")
	}
	var userJSON identity.JSON
	err = json.Unmarshal(valueBytes, &userJSON)
	if err != nil {
		return nil, errors.Wrap(err, "unmarshal user JSON failed")
	}
	user := identity.NewUser(name, userJSON.MspID)
	user.SetRoles(userJSON.Roles)
	user.SetEnrollmentCertificate(userJSON.EnrollmentCertificate)
	key, err := c.cryptoSuite.GetKey(userJSON.PrivateKeySKI)
	if err != nil {
		return nil, errors.Wrap(err, "cryptoSuite GetKey failed")
	}
	user.SetPrivateKey(key)
	return user, nil
}
LoadUserFromStateStore ...

Restore the state of this member from the key value store (if found).  If not found, do nothing.
@returns {Promise} A Promise for a {User} object upon successful restore, or if the user by the name
does not exist in the state store, returns null without rejecting the promise
package fabricclient
import (
	"encoding/json"
	config "github.com/hyperledger/fabric-sdk-go/api/apiconfig"
	fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
	"github.com/hyperledger/fabric-sdk-go/api/kvstore"
	"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common"
	pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
	"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
	channel "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/channel"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/chconfig"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/identity"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/resource"
	"github.com/hyperledger/fabric-sdk-go/pkg/logging"
	"github.com/pkg/errors"
)
var logger = logging.NewLogger("fabric_sdk_go")
type Client struct {
	channels        map[string]fab.Channel
	cryptoSuite     apicryptosuite.CryptoSuite
	stateStore      kvstore.KVStore
	signingIdentity fab.IdentityContext
	config          config.Config
	signingManager  fab.SigningManager
}
type fabContext struct {
	fab.ProviderContext
	fab.IdentityContext
}
func NewClient(config config.Config) *Client {
	channels := make(map[string]fab.Channel)
	c := Client{channels: channels, config: config}
	return &c
}
func (c *Client) NewChannel(name string) (fab.Channel, error) {
	if _, ok := c.channels[name]; ok {
		return nil, errors.Errorf("channel %s already exists", name)
	}
	ctx := fabContext{ProviderContext: c, IdentityContext: c.signingIdentity}
	channel, err := channel.New(ctx, chconfig.NewChannelCfg(name))
	if err != nil {
		return nil, err
	}
	c.channels[name] = channel
	return c.channels[name], nil
}
func (c *Client) Config() config.Config {
	return c.config
}
func (c *Client) Channel(id string) fab.Channel {
	return c.channels[id]
}
func (c *Client) QueryChannelInfo(name string, peers []fab.Peer) (fab.Channel, error) {
	return nil, errors.Errorf("Not implemented yet")
}
func (c *Client) SetStateStore(stateStore kvstore.KVStore) {
	c.stateStore = stateStore
}
func (c *Client) StateStore() kvstore.KVStore {
	return c.stateStore
}
func (c *Client) SetCryptoSuite(cryptoSuite apicryptosuite.CryptoSuite) {
	c.cryptoSuite = cryptoSuite
}
func (c *Client) CryptoSuite() apicryptosuite.CryptoSuite {
	return c.cryptoSuite
}
func (c *Client) SigningManager() fab.SigningManager {
	return c.signingManager
}
func (c *Client) SetSigningManager(signingMgr fab.SigningManager) {
	c.signingManager = signingMgr
}
func (c *Client) SaveUserToStateStore(user fab.User) error {
	if user == nil {
		return errors.New("user required")
	}
	if user.Name() == "" {
		return errors.New("user name is empty")
	}
	if c.stateStore == nil {
		return errors.New("stateStore is nil")
	}
	userJSON := &identity.JSON{
		MspID:                 user.MspID(),
		Roles:                 user.Roles(),
		PrivateKeySKI:         user.PrivateKey().SKI(),
		EnrollmentCertificate: user.EnrollmentCertificate(),
	}
	data, err := json.Marshal(userJSON)
	if err != nil {
		return errors.Wrap(err, "marshal json return error")
	}
	err = c.stateStore.Store(user.Name(), data)
	if err != nil {
		return errors.WithMessage(err, "stateStore SetValue failed")
	}
	return nil
}