I am writing a program that uses branch labels. It uses your example pattern to break out of a loop when a particular `select` situation occurs. Branch labels are not indented because they represent unusual locations for modifying the flow of control. This seems perfectly cromulent to me.
A branch label does not have to begin with a capital letter. Where did you get the idea it has to begin with a capital letter? Also, what you call a "loop" label is better characterized as a branch label. On Mon, Oct 2, 2023 at 10:12 PM 王富民awaw <a...@nandalu.idv.tw> wrote: > I wonder does anyone know the reason and history of why loop labels are > styled as such: > > * Labels are *unindented*. > All Go constructs, such as fields in structs indent to the right. > Why does loop labels unindented to the left? > * Labels start with capital letters. > Since all other Go identifiers start with lower case, why is loop label > an exception? > > ``` > func foo() { > ok := true > // Why is the loop label unindented backwards to the left? > Loop: > for { > switch { > case ok: > // Why is the loop label capitalized? > break Loop > } > } > } > ``` > > Thanks in advance to those who are ancient enough to share the story > behind loop labels. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/c2bfd4c3-4a0e-4a53-b8a7-d700543c4ef0n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/c2bfd4c3-4a0e-4a53-b8a7-d700543c4ef0n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD_q1zwgGMqpJPp3gKea5Rzb11T9w-iiTdxpFP-w2nii9A%40mail.gmail.com.