Problems with CGO and PKCS11.h in Windows 10

While writing my Golang code I ended up encountering two errors that I don’t know how to fix. Please, does anyone happen to know??

The First Error happened when I put “import C”, but the GO code I’m creating needs CGO to work so I don’t know why this error is happening or how to fix it.

The Second Error happens when I run the program. I tested and this error has no connection with the first error. I don’t understand why this error is happening or how to fix it, but I already checked the path described and the file described is there.

This is my main.go

package main

// #include "C:\src\github.com\miekg\pkcs11\pkcs11.h"
import "C"

import (
	"fmt"

	"github.com/miekg/pkcs11"
)

func main() {
	p := pkcs11.New("aetpkss1.dll")
	err := p.Initialize()

	if err != nil {
		panic(err)
	}

	defer p.Destroy()
	defer p.Finalize()

	slots, err := p.GetSlotList(true)
	if err != nil {
		panic(err)
	}

	session, err := p.OpenSession(slots[0], pkcs11.CKF_SERIAL_SESSION|pkcs11.CKF_RW_SESSION)
	if err != nil {
		panic(err)
	}
	defer p.CloseSession(session)

	err = p.Login(session, pkcs11.CKU_USER, "1234")
	if err != nil {
		panic(err)
	}
	defer p.Logout(session)

	p.DigestInit(session, []*pkcs11.Mechanism{pkcs11.NewMechanism(pkcs11.CKM_SHA_1, nil)})
	hash, err := p.Digest(session, []byte("this is a string"))
	if err != nil {
		panic(err)
	}

	for _, d := range hash {
		fmt.Printf("%x", d)
	}

	fmt.Println()
}

And this is my settings.json

{
    "go.buildTags": "cgo",
    "go.toolsEnvVars": {
        "CGO_ENABLED": "1"
    } /* , "go.toolsGopath": "C:\\msys64\\ucrt64\\bin;${workspaceFolder}\\bin;${env:GOPATH}\\bin" */
}

Unfortunately I have no experience with CGO so I can’t be too much help here. But there were some hidden (which is ridiculous as they are potentially helpful) comments on the mentioned issue:

Have you tried those fixes? Also - maybe back up and follow this guide and see where it gets you:

Thank you for the help but the problem still happening