Skip to content

go2go example code to demonstrate implementations using the current Go generics proposal.

Notifications You must be signed in to change notification settings

kalexmills/go2go-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 

Repository files navigation

Go2Go Snippets

To better understand the impact of the Go generics proposal, this repository collects a list of solutions to problems that could benefit from generics and links to implementations that run on The go2go Playground. Multiple implementations for the same problem are highly encouraged. Having a variety of solutions to look at and compare will help the community learn about approaches to generics that may and may not be useful.

Pull requests are welcome, both for solutions to the problems below and solutions of new problems! Just modify this file to a link to a go2go example that includes a main method demonstrating correct usage. Maintainers may run format on your submission and modify the link before merging, but we will preserve your original commit in the history.

If you are copying from an online source, please make sure 1) you are able to do so and 2) include a link back to the original material.

If you see an implementation in this list that you have questions about or want to discuss, start a conversation in the issue tracker. Please follow the Go Community Code of Conduct.

Data structures

  • Queue: FIFO access to a list
    • enqueue and dequeue (standard example) (go2go)

Algorithms

  • Min/Max: find smallest/largest element in a collection
    • using a numeric interface (go2go)
  • Reverse: reverse an ordered collection
  • Union/Intersection: perform basic set theory
    • using 'sets' -- maps with empty structs for values (go2go)
  • Transform Collections: apply a function to each element of a collection and return the modified collection.
    • mapping over slices (go2go)
  • Average/Standard Deviation: compute statistical moments of a collection
    • TODO
  • Shortest Path: find shortest path in a graph
    • TODO

Concurrency

  • Channel Join: combine two channels into one
    • async implementation (go2go)
  • Parallel allOf: call a list of functions in parallel, returning a slice of results
    • retrieve response code from parallel HTTP requests (go2go)
  • Parallel oneOf: call a list of functions in parallel, return the first function to finish, cancelling the remainder and not leaking any goroutines.
    • TODO
  • Channel Timeout: read from a channel with a timeout
    • TODO

About

go2go example code to demonstrate implementations using the current Go generics proposal.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published