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

No error handling for Go #9

Open
ns-cweber opened this issue Jan 9, 2017 · 3 comments
Open

No error handling for Go #9

ns-cweber opened this issue Jan 9, 2017 · 3 comments

Comments

@ns-cweber
Copy link

ns-cweber commented Jan 9, 2017

Compiling the following program to Go produces no error handling logic:

import sys

print(int(sys.argv[1]))
package main

import (
	"strconv"
	"os"
	"fmt"
)

func main() {
	_int, _ := strconv.Atoi(os.Args[1]) // error handling missing
	fmt.Println(_int)
}

When we go run foo.go "not_an_int", the program prints 0 and exists successfully. When we python3 foo.py "not_an_int", we see:

Traceback (most recent call last):
  File "foo.py", line 3, in <module>
    print(int(sys.argv[1]))
ValueError: invalid literal for int() with base 10: 'not_an_int'
@alehander92
Copy link
Collaborator

That's right, a middleware that implements Go-style error checks was in the works, however currently that's not implemented.

As a whole this projects is currently on hold: I am currently focused on my job and different projects. I'll probably finish a more stable new version if there is any interest in it. (The people interested in this project had vastly different usecases/wishes for its functionality so I decided to wait for a compelling usecase)

@ns-cweber
Copy link
Author

Fair enough. I'm certainly interested in this project. I'm contributing to Grumpy (a Python runtime in Go) which aims to support most of Python2.7 in all its dynamic glory, but it does so by compiling everything into a Go *Object struct. Ideally, I would like a hybrid approach, which compiles to idiomatic Go whenever provably possible, falling back to dynamic *Objects when not. This is well outside the scope of this project and probably not feasible, but I'm sure I can learn a lot toward that end by following this project.

@alehander92
Copy link
Collaborator

That's a very nice idea, but you're right, it's outside the scope of this project. Grumpy is pretty interesting, I wonder if somebody is building a Ruby runtime on Go too.

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