Skip to content

Instantly share code, notes, and snippets.

@Enapiuz
Last active February 14, 2019 15:42
Show Gist options
  • Save Enapiuz/e7b77e7d5b19ef31bb984a4d0b1d6e01 to your computer and use it in GitHub Desktop.
Save Enapiuz/e7b77e7d5b19ef31bb984a4d0b1d6e01 to your computer and use it in GitHub Desktop.
Elixir vs Go
with(
{:ok, data} <- File.read "testdata/hello",
{:ok, config} <- Poison.decode data,
{:ok, result} <- Peka.do_something config
) do
IO.puts result
else
{:error, :enoent} ->
IO.puts "file not found"
{:error, :peka_mega_error} ->
IO.puts "peka died"
{:error, :peka_general_error} ->
IO.puts "peka is sad"
{:error, error} ->
IO.puts "Unknown error {#inspect error}"
IO.inspect error
end
func main() {
content, err := ioutil.ReadFile("testdata/hello")
if err != nil {
log.Fatal(err)
}
var Config config
err := json.Unmarshal(content, &config)
if err != nil {
log.Fatal(err)
}
err := peka.DoSomething(config)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment