splunk / splunk/stef

Finalize generated Go API

Open
#285 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Go
Dominant language
Java
Stars
11
Forks
6
Avg merge
55m
Merged PRs (30d)
1

Description

The API currently looks like this:

Struct
// Return value of “Field” of primitive type
S.Field() <type>

// Return pointer to “Field” of non-primitive type
// For dict-enabled types returned value is readonly.
S.Field() *<type>

// Set value of “Field” of primitive type
// For optional fields also sets the presence flag
S.SetField(val <type>)

// Set value of “Field” of dict-enabled non-primitive type
// For optional fields also sets the presence flag
S.SetField(val *<type>)

// Check if an optional “Field” is present
S.HasField() bool

// Unset presence flag for an optional “Field”
S.UnsetField()
Oneof
// Return the type of the current choice in oneof
S.Type() <int-type>

// Return value of primitive type, assuming the current choice
// of oneof is “Field”.
S.Field() <type>

// Return pointer to non-primitive type, assuming the current choice
// of oneof is “Field”.
// For dict-enabled types returned value is readonly.
S.Field() *<type>

// Set value of primitive type. Sets the choice of oneof to “Field”
// For optional fields also sets the presence flag
S.SetField(val <type>)

// Set value of dict-enabled non-primitive type by pointer.
// Sets the choice of oneof to “Field”
S.SetField(val *<type>)
Array
// Return number of elements
A.Len()

// Return element at index i (primitive type).
// Panics if index is out of range.
A.At(i int) <type>

// Set element at index i (primitive type)
// Panics if index is out of range.
A.SetAt(i int, val <type>)

// Return element at index i (non-primitive type)
// Panics if index is out of range.
// For dict-enabled types returned value is readonly.
A.At(i) *<type>

// Set element at index i (dict-enabled, non-primitive type)
// Panics if index is out of range.
A.SetAt(i int, val *<type>)

// Set length of the array. If array length grows, new elements
// are appended at the end in a zero-initialized state.
// For non-primitive types subsequent At() for new elements returns non-nil pointer.
A.EnsureLen(len int)
Multimap
// Return number of key-value pairs
M.Len()

// Return key-value pair at index i
M.At(i int) *<KeyValueType>

// Return key of the pair. Returns a pointer for non-primitive types.
<KeyValueType>.Key() <type>

// Return value of the pair. Returns a pointer for non-primitive types.
<KeyValueType>.Value() <type>

// Set the key of the pair (primitive type)
<KeyValueType>.SetKey(key <type>)

// Set the key of the pair (dict-enabled non-primitive type).
<KeyValueType>.SetKey(key *<type>)

// Set the value of the pair (primitive type)
<KeyValueType>.SetValue(key <type>)

// Set the value of the pair (dict-enabled non-primitive type).
<KeyValueType>.SetValue(key *<type>)

// Set length of the multimap. If the length grows, new key-value pairs
// are appended at the end in a zero-initialized state.
// For non-primitive types subsequent At() for new key-value pairs return
// non-nil pointer.
M.EnsureLen(len int)

We want to review and decide if this is the desirable API or we want to change it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the proposed Struct, Oneof, Array, and Multimap APIs in the issue body. Compare their behavior for primitive, non-primitive, optional, and dict-enabled values, then document whether the API should be accepted or changed. Done means a clear design decision is recorded; no files or tests are identified in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.