I'm using the "Google APIs Client Library for Go" ( https://github.com/googleapis/google-api-go-client ) and it has an issue supporting the Slides API where a zero-based index request property is required but the struct definition indicates omitempty
so zero values are omitted. I want to fork and modify this code to remove the omitempty
values.
The specific code is here:
https://github.com/googleapis/google-api-go-client/blob/master/slides/v1/slides-gen.go#L4060-L4069
type Range struct {
// EndIndex: The optional zero-based index of the end of the
// collection.
// Required for `FIXED_RANGE` ranges.
EndIndex int64 `json:"endIndex,omitempty"`
// StartIndex: The optional zero-based index of the beginning of the
// collection.
// Required for `FIXED_RANGE` and `FROM_START_INDEX` ranges.
StartIndex int64 `json:"startIndex,omitempty"`
I've posted this topic here issue 433, but I'd also like to fork and modify the code to overcome this.
I run into the following issues when attempting to fork and modify this code.
First, it expects to only be imported using its original package name using the following package definition comment.
package slides // import "google.golang.org/api/slides/v1"
This comment results in the following error when attempting to use a fork:
code in directory /path/to/fork/google-api-go-client/slides/v1 expects import "google.golang.org/api/slides/v1"
Removing the comment from the package definition line allows the package to be loaded but then the following error is encountered which indicates an internal library is needed.
use of internal package google.golang.org/api/internal/gensupport not allowed
Is there any way to fork and modify this code?
Update
I was able to overcome the internal
package issue with the following from Clive Makamara here.
$ ln -s /path/to/fork/google-api-go-client $GOPATH/google.golang.org/api
Unfortunately, this doesn't fully resolve the issue as other range types require the fields to be omitted, resulting in the following error:
googleapi: Error 400: Invalid requests[5].createParagraphBullets: The textRange startIndex must not be specified for range type ALL, badRequest
Since some range types require StartIndex
and others require it to not be present, it seems like having separate range structs may be necessary.
My current workaround is to use the client as-is but add a small font size newline prefix so that I never have to update a text range starting at index 0.