Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proof is in the pudding - go playground for examples #226

Open
headwinds opened this issue Sep 25, 2022 · 12 comments
Open

proof is in the pudding - go playground for examples #226

headwinds opened this issue Sep 25, 2022 · 12 comments

Comments

@headwinds
Copy link

headwinds commented Sep 25, 2022

first off, fantastic library! this is more praise and wanting to help myself and others learn than an issue.

Has anyone already started to build a collection of examples using the go playground? The docs are excellent - a working example would be icing.

I was struggling a bit to learn how to use filter against a collection so created this playground to sort it out.

@samber
Copy link
Owner

samber commented Oct 2, 2022

hi @headwinds

I made a small PR: #230

Can you review it, please?

As soon as we are ok with this first PR, we can distribute work ;)

@headwinds
Copy link
Author

@samber I've reviewed & much approve - that's an excellent approach and should encourage more devs to contribute examples!

@samber
Copy link
Owner

samber commented Oct 3, 2022

Can I ask you to write some examples for find.go ? I will keep pushing for slice.go and map.go.

I liked the example you provided above, but don't spend too much time with such big samples! ;)

I gonna write some instructions to future contributors in a PR template.

@samber
Copy link
Owner

samber commented Oct 3, 2022

I just added:

  • condition_example_test.go
  • map_example_test.go
  • math_example_test.go
  • slice_example_test.go
  • string_example_test.go

@headwinds
Copy link
Author

cool I'll take a look at your samples and could write one similar for find.go - keep it small simple - 😘

@headwinds
Copy link
Author

find playground

or maybe not so simple but I always look for examples that have both a simple string and an object

@headwinds
Copy link
Author

@samber
Copy link
Owner

samber commented Oct 4, 2022

Can I suggest some changes ?

-> https://go.dev/play/p/c2lDl0vxr-V

  • i separated your examples into 2 functions to make it clear (go playground editor sucks)
  • I added a check for ok

In your last snippet, I'm not sure declaring ProductSearchResult is necessary. It makes the example longer to understand. You can just return (Product, error) instead.

@headwinds
Copy link
Author

@samber Yes this is great - let's go with your version - I'm pretty new to go and can see the experience in your upgrades!

@headwinds
Copy link
Author

headwinds commented Oct 4, 2022

Actually one small change - can we flip the function names and order - so that string example runs first then the struct example - simple before complex

Currently it prints:

We also found the product Dragon Fruit ($3.75) 
We found the coconut

So I'd like to read:

We found the coconut
We also found the product Dragon Fruit ($3.75) 

And ship it!

@samber
Copy link
Owner

samber commented Oct 6, 2022

Yes, no worries ;)

Examples need to be clear and simple to read. This is the only requirement ;)

@samber
Copy link
Owner

samber commented Oct 7, 2022

Still a few examples missing:

  • channel_example_test.go
  • concurrency_example_test.go
  • find_example_test.go
  • func_example_test.go
  • intersect_example_test.go
  • type_manipulation_example_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants