Go code examples · runnable

20 runnable Go code examples.

Open any Go example to explore the code and run it online. No setup, no signup.

Go

How to reverse a string in GoHow to convert a string to an int in GoHow to check if a key exists in a map in GoHow to check if a slice contains an element in GoHow to sort a slice in GoHow to remove an element from a slice in GoHow to check if a string contains a substring in GoHow to split a string in GoHow to concatenate strings in GoHow to trim whitespace from a string in GoHow to convert an int to a string in GoHow to iterate over a map in GoHow to remove a key from a map in GoHow to remove duplicates from a slice in GoHow to loop with an index in GoHow to convert a struct to JSON in GoHow to parse JSON into a struct in GoHow to format a date in GoHow to wait for goroutines to finish in GoHow to handle errors in Go
Questions & answers

Go examples, explained

Can I run these Go code examples?

Yes. Open any Go example to edit and run its code on the CompileBytes engine without installing anything.

Is this free? Do I need an account?

Every example is free to read, run, edit, and copy. No account is required.

Can I copy these into my own projects?

Yes. These examples are designed to be copied and adapted to your own code.

Where can I run my own code?

Open the Go compiler from the main playground catalog, then paste or write any code you want to run.