go compile error: unknown field in struct literal-ThrowExceptions

Exception or error:

I have a go package that has the following struct:

package transforms
type MqttConfig struct {
    Qos            byte  

type KeyCertPair struct { 
    KeyFile      string 

In my main.go, I import the package and use both of them liek this:

    import ( sdkTransforms "github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms")

    type AWSMQTTConfig struct {
        MQTTConfig  *sdkTransforms.MqttConfig
        KeyCertPair *sdkTransforms.KeyCertPair

    config := AWSMQTTConfig{}

    pair := &sdkTransforms.KeyCertPair{
            KeyFile:  mqttKey,

    mqttcfg := &sdkTransforms.MqttConfig{
            Qos:            2,    

But only the second usage gives me this compile error:

unknown field 'Qos' in struct literal of type transforms.MqttConfig

I don’t understand what’s wrong.

How to solve:

It is possible that you are pointing to a version of the sdkTransforms package that doesn’t have that field for MqttConfig. You can do a go get <module> to get the latest version and try again.

Leave a Reply

Your email address will not be published. Required fields are marked *