func FindSlotByLabel(p *pkcs11.Ctx, slotLabel string) (slot uint, index int, err error) {
	var slotFound bool
	slots, err := p.GetSlotList(true)
	if err == nil {
		for i, s := range slots {
			tInfo, errGt := p.GetTokenInfo(s)
			if errGt != nil {
				err = errGt
				return
			}
			if slotLabel == tInfo.Label {
				slotFound = true
				slot = s
				index = i
				fmt.Printf("PKCS11 provider found specified slot label: %s (slot: %d, index: %d)\n", slotLabel, slot, i)
				break
			}
		}
	}
	if !slotFound {
		err = errors.New(fmt.Sprintf("Could not find slot with label: %s", slotLabel))
	}
	return
}
/* Return the slotID of token label
package pkcs11wrapper
import (
	"crypto/elliptic"
	"crypto/sha256"
	"encoding/hex"
	"errors"
	"fmt"
	"os"
	"github.com/miekg/pkcs11"
	"github.com/olekukonko/tablewriter"
)
type Pkcs11Library struct {
	Path string
	Info pkcs11.Info
}
type Pkcs11Wrapper struct {
	Library Pkcs11Library
	Context *pkcs11.Ctx
	SlotLabel string
	Session   pkcs11.SessionHandle
	SlotPin string
}
type Pkcs11Object struct {
	ObjectHandle pkcs11.ObjectHandle
	Count     string
	CKA_CLASS string
	CKA_LABEL string
	CKA_ID    string
}
func (p11w *Pkcs11Wrapper) InitContext() (err error) {
	if _, err = os.Stat(p11w.Library.Path); os.IsNotExist(err) {
		return
	}
	p11w.Context = pkcs11.New(p11w.Library.Path)
	err = p11w.Context.Initialize()
	if err != nil {
		return
	}
	p11w.Library.Info, err = p11w.Context.GetInfo()
	return
}
func (p11w *Pkcs11Wrapper) InitSession() (err error) {
	slot, _, err := FindSlotByLabel(p11w.Context, p11w.SlotLabel)
	if err != nil {
		return
	}
	p11w.Session, err = p11w.Context.OpenSession(slot, pkcs11.CKF_SERIAL_SESSION|pkcs11.CKF_RW_SESSION)
	return
}
func (p11w *Pkcs11Wrapper) Login() (err error) {
	err = p11w.Context.Login(p11w.Session, pkcs11.CKU_USER, p11w.SlotPin)
	return
}
func (p11w *Pkcs11Wrapper) CloseContext() {
	p11w.Context.Logout(p11w.Session)
	p11w.Context.CloseSession(p11w.Session)
	p11w.Context.Finalize()
	p11w.Context.Destroy()
	return
}
func (p11w *Pkcs11Wrapper) FindObjects(template []*pkcs11.Attribute, max int) (p11ObjHandlers []pkcs11.ObjectHandle, moreThanMax bool, err error) {
	err = p11w.Context.FindObjectsInit(
		p11w.Session,
		template,
	)
	if err != nil {
		return
	}
	p11ObjHandlers, moreThanMax, err = p11w.Context.FindObjects(p11w.Session, max)
	if err != nil {
		return
	}
	err = p11w.Context.FindObjectsFinal(p11w.Session)
	if err != nil {
		return
	}
	return
}