Skip to content

x/tools/cmd/stringer: does not find constants across multiple groups #11582

Closed
@josharian

Description

@josharian

Given input:

package a

type Num int

// Small numbers
const (
    One Num = iota
    Two
)

// Big numbers
const (
    Fourteen Num = iota
    EleventyOne
)

stringer generates strings only for the first group:

// generated by stringer -type=Num; DO NOT EDIT

package a

import "fmt"

const _Num_name = "OneTwo"

var _Num_index = [...]uint8{0, 3, 6}

func (i Num) String() string {
    if i < 0 || i+1 >= Num(len(_Num_index)) {
        return fmt.Sprintf("Num(%d)", i)
    }
    return _Num_name[_Num_index[i]:_Num_index[i+1]]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions