sparsefieldsgen

command
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Command sparsefieldsgen generates typed string enums and per-list containers for v3 sparse fieldsets.

It scans a Go package for struct type declarations that carry either of two markers on their doc comment:

  • sparsefields:gen [=CustomTypeName] Marks an entity struct (e.g. Task, Project). Emits a named string type plus one constant per JSON-tagged field on the struct (same-package embedded structs are flattened).

  • sparsefields:list [=CustomTypeName] Marks a *ListResponse struct. Emits a typed container struct (e.g. TaskListFields) whose fields mirror the response's main slice and each entry of its Included sub-struct, plus an `apply(url.Values)` method that writes the appropriate fields[entityKey]=… query parameters via twapi.ApplySparseFields.

Usage (typically invoked via //go:generate from the target package):

//go:generate go run github.com/teamwork/twapi-go-sdk/internal/sparsefieldsgen

By default it scans the current working directory and writes `sparse_fields_gen.go` next to the sources. Both can be overridden with the -src and -out flags.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL