Last active
February 14, 2019 15:42
-
-
Save Enapiuz/e7b77e7d5b19ef31bb984a4d0b1d6e01 to your computer and use it in GitHub Desktop.
Elixir vs Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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