Skip to content

go/printer: consider permitting one-line "enum" const decls #13403

Open
@griesemer

Description

@griesemer

A declaration of the form:

const (
    Do = iota; Re; Mi; Fa; Sol; La; Ti;
)

gets formatted as:

const (
    Do = iota
    Re
    Mi
    Fa
    Sol
    La
    Ti
)

The former is close to what in other languages might be achieved with an "enum" declaration. If there's several such simple const decls, the latter form uses undue amount of space w/o much readability benefit.

Consider recognizing this special case and not introduce line-breaks if there were none in the original source.

Activity

self-assigned this
on Nov 25, 2015
added this to the Unplanned milestone on Nov 25, 2015
agnivade

agnivade commented on Apr 26, 2018

@agnivade
Contributor

I can take a stab at this. @griesemer - Let me know if you already had something planned.

griesemer

griesemer commented on Apr 26, 2018

@griesemer
ContributorAuthor

@agnivade You're welcome to investigate and play with it but I am probably not going to look at this (or any related CLs) any time soon. We have a freeze coming up on May 1 and this is not important at all and we many more important issues to tackle at the moment. Thanks.

agnivade

agnivade commented on Apr 26, 2018

@agnivade
Contributor

Got it. Thanks.

gopherbot

gopherbot commented on Apr 27, 2018

@gopherbot
Contributor

Change https://golang.org/cl/109795 mentions this issue: go/printer: allow single-line const enum declarations

added
NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
on Sep 5, 2018
griesemer

griesemer commented on Sep 5, 2018

@griesemer
ContributorAuthor

The pending CL seems ok but I think we need to determine if we actually want this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @agnivade@griesemer@gopherbot

        Issue actions

          go/printer: consider permitting one-line "enum" const decls · Issue #13403 · golang/go