Do you have a minimal runnable go code that contain all key words in go?

237 views
Skip to first unread message

xie cui

unread,
Dec 5, 2021, 10:54:04 AM12/5/21
to golang-nuts
show me you code

ben...@gmail.com

unread,
Dec 5, 2021, 4:10:54 PM12/5/21
to golang-nuts
Not strictly "minimal" -- it uses some keywords twice, and I'm sure it's longer than it needs to be, but here you go: https://go.dev/play/p/XPoqfI8RmyH

On Monday, December 6, 2021 at 4:54:04 AM UTC+13 cuiw...@gmail.com wrote:
show me you code

Michael Ellis

unread,
Dec 6, 2021, 8:33:52 AM12/6/21
to golang-nuts
Nice! Noticed it didn't have "new" so I changed the counter initializer in main() from

    var c = counter

to 

    p := new(counter)
    var c = *p

Axel Wagner

unread,
Dec 6, 2021, 8:47:41 AM12/6/21
to golang-nuts
`new` is not a keyword, it is a predeclared identifier.
Here's a valid program that contains every keyword exactly once: https://go.dev/play/p/YxfkoYDTN4h

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/851b403a-dc73-487f-b10e-e1608cb8cda2n%40googlegroups.com.
Message has been deleted

Rob Pike

unread,
Dec 7, 2021, 7:20:21 PM12/7/21
to ben...@gmail.com, golang-nuts
It's easy to fold a few things together: https://go.dev/play/p/6lpZmGH9iJb

Nice work though.

On Wed, Dec 8, 2021 at 5:15 AM ben...@gmail.com <ben...@gmail.com> wrote:
>
> Heh, nice! I made it three bytes smaller by defining "const t = true" (true was used in 2 places). https://go.dev/play/p/-3SvzKYjGSr ... I can't think of any ways to reduce its (formatted) size further off the top of my head, but I'm sure there's bound to be something.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/378e15b4-11f5-4084-860f-250fe92bd33bn%40googlegroups.com.

Rob Pike

unread,
Dec 7, 2021, 7:21:31 PM12/7/21
to ben...@gmail.com, golang-nuts
Oh, it needs to be runnable. Never mind.

-rob
Reply all
Reply to author
Forward
Message has been deleted
0 new messages