0

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{} //FIRST pair := &sdkTransforms.KeyCertPair{ KeyFile: mqttKey, } //SECOND 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.

6
  • 1
    Is it possible that you are pointing to a version of the sdkTransforms package that doesn't have that field for MqttConfig? Commented Oct 22, 2019 at 15:26
  • @bserdar Actually the MqttConfig changed recently and a new field was added, but Qos is an old field, should be already there. Is there any check I can make to see what version I am picking? The makefile looks ok. Commented Oct 22, 2019 at 15:32
  • check go.mod, see which version it is looking at. Commented Oct 22, 2019 at 15:36
  • @bserdar I have cloned the repo and it contains the correct struct, but in the go cache I have the old version. I don't know how to clean the environment but your answer is right. If you answer, I will vote Commented Oct 22, 2019 at 15:50
  • In your AWSMQTTConfig struct, MqttConfig and KeyCertPair are NOT embedded. But the error you shared in your question concerns transforms.MqttConfig, a different struct. Can you share the structure the error references ? Commented Oct 22, 2019 at 15:57

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.