programming.dev
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
austinM to GolangEnglish · 2 years ago

Go’s best-kept secret: executable examples

bitfieldconsulting.com

external-link
message-square
5
link
fedilink
  • cross-posted to:
  • [email protected]
20
external-link

Go’s best-kept secret: executable examples

bitfieldconsulting.com

austinM to GolangEnglish · 2 years ago
message-square
5
link
fedilink
  • cross-posted to:
  • [email protected]
Go’s best-kept secret: executable examples — Bitfield Consulting
bitfieldconsulting.com
external-link
Did you know that Go lets us provide executable code examples as part of our documentation? It’s pretty neat. Let’s take a tour of this useful feature and see how it works.
  • morgen@infosec.pub
    link
    fedilink
    English
    arrow-up
    4
    ·
    2 years ago

    I have not seen this before. Thanks for sharing. Do you know any projects that utilize this, so I can see an example implementation of this?

    • Oliver Lowe@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 years ago

      Do you know any projects that utilize this, so I can see an example implementation of this?

      The sort package in the standard library uses testable examples (source code).

    • RandomDevOpsDudeM
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 years ago

      ExampleEcho

      going to

      func Echo doc Example

      (and many more)

    • austinOPM
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 years ago

      The go stdlib uses it a lot. For example, the strings package

Golang

golang

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

This is a community dedicated to the go programming language.

Useful Links:

  • Go Website
  • Effective Go
  • Go by Example
  • How to Start a Go Project

Rules:

  • Posts must be relevant to Go
  • No NSFW content
  • No hate speech, bigotry, etc
  • Try to keep discussions on topic
  • No spam of tools/companies/advertisements
  • It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 9 users / day
  • 53 users / week
  • 80 users / month
  • 187 users / 6 months
  • 580 local subscribers
  • 2.43K subscribers
  • 177 Posts
  • 308 Comments
  • Modlog
  • mods:
  • Ategon
  • RandomDevOpsDude
  • austin
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org