Build golang sdk failed after migrate to V10

250 views
Skip to first unread message

Zhenjin Hu

unread,
Feb 11, 2022, 6:38:20 AM2/11/22
to Google Ads API and AdWords API Forum
It works well when I build V9 api. 
But after migrate to V10, I got the below error:
google/ads/googleads/services/experiment_arm_service.pb.go:199:47: undefined: resources.ExperimentArm
google/ads/googleads/services/experiment_arm_service.pb.go:206:47: undefined: resources.ExperimentArm
google/ads/googleads/services/experiment_arm_service.pb.go:226:10: undefined: resources.ExperimentArm

The error position is as below:
```golang
func (x *ExperimentArmOperation) GetCreate() *resources.ExperimentArm { // line:199
if x, ok := x.GetOperation().(*ExperimentArmOperation_Create); ok {
return x.Create
}
return nil
}

func (x *ExperimentArmOperation) GetUpdate() *resources.ExperimentArm { // line:206
if x, ok := x.GetOperation().(*ExperimentArmOperation_Update); ok {
return x.Update
}
return nil
}

type ExperimentArmOperation_Create struct {
// Create operation
Create *resources.ExperimentArm `protobuf:"bytes,1,opt,name=create,proto3,oneof"` // line: 226
}
```

I can find the type:resources.ExperimentArm in the generated codes, in resources pkg.
```golang
type ExperimentArm struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields

// Immutable. The resource name of the experiment arm.
// Experiment arm resource names have the form:
//
// `customers/{customer_id}/experimentArms/{TrialArm.trial_id}~{TrialArm.trial_arm_id}`
ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3" json:"resource_name,omitempty"`
// Immutable. The experiment to which the ExperimentArm belongs.
Trial string `protobuf:"bytes,2,opt,name=trial,proto3" json:"trial,omitempty"`
// Required. The name of the experiment arm. It must have a minimum length of 1 and
// maximum length of 1024. It must be unique under an experiment.
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
// Whether this arm is a control arm. A control arm is the arm against
// which the other arms are compared.
Control bool `protobuf:"varint,4,opt,name=control,proto3" json:"control,omitempty"`
// Traffic split of the trial arm. The value should be between 1 and 100
// and must total 100 between the two trial arms.
TrafficSplit int64 `protobuf:"varint,5,opt,name=traffic_split,json=trafficSplit,proto3" json:"traffic_split,omitempty"`
// List of campaigns in the trial arm. The max length is one.
Campaigns []string `protobuf:"bytes,6,rep,name=campaigns,proto3" json:"campaigns,omitempty"`
// Output only. The in design campaigns in the treatment experiment arm.
InDesignCampaigns []string `protobuf:"bytes,7,rep,name=in_design_campaigns,json=inDesignCampaigns,proto3" json:"in_design_campaigns,omitempty"`
}
```

So, it strange to get the undefined: resources.ExperimentArm error.

Can anyone tell me how to fix it? Thanks

Best regards!

Google Ads API Forum Advisor

unread,
Feb 14, 2022, 1:58:33 AM2/14/22
to zhen...@gmail.com, adwor...@googlegroups.com
Hi Zhenjin,

Thank you for raising your concern.

You may try to compile your Go library to see if the error can be addressed by running protoc directly on these source files and you can follow the instructions at https://github.com/protocolbuffers/protobuf for Go to build these files. 

If the error persists, I would suggest to use one of the supported client libraries as it is more stable and our team can provide support to it as any other client libraries like Go library are outside of our scope.

Regards,
Google Logo
Ernie John
Google Ads API Team
 


ref:_00D1U1174p._5004Q2W6Nyg:ref

Zhenjin Hu

unread,
Feb 16, 2022, 5:52:23 AM2/16/22
to Google Ads API and AdWords API Forum
Hi Ernie,

Thank you for your reply!

I use the follow script to gen go source files from protobuf source files:

        for file in googleapis/google/ads/googleads/v10/**/*.proto; do \
                echo "gen go code from proto $(basename $file)"; \
                protoc -I=googleapis/ --go_out=plugins=grpc,paths=source_relative:./ $file; \
        done

and NO error raise in this step.

The error raise when I use go build command to build the generated go source files.

If I change v10 to v9 or v8, then it works well.

---------

Unfortunately, our system is build by golang, so we can't use any of the client libraries.

Google Ads API Forum Advisor

unread,
Feb 16, 2022, 11:58:29 PM2/16/22
to zhen...@gmail.com, adwor...@googlegroups.com
Hi Zhenjin,

So that I can raise your concern to my team, would you be able to provide more generated logs where we can see the issue? 

You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Zhenjin Hu

unread,
Feb 17, 2022, 7:03:08 AM2/17/22
to Google Ads API and AdWords API Forum
Hi Ernie,

Thanks for reaching out!

I've figged out the issue. This is caused by the filename of experiment_arm.proto added in V10. 

The protoc compile this file and gen a go  source file named experiment_arm.pb.go by default. 

This go source filename make the go build system  think it should only compiled on arm arch machine. 

So I changed the generated filename to experiment_arm0.pb.go. It works now!

Thank you any way!
Reply all
Reply to author
Forward
0 new messages