Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

No error handling for Go #9

Open
Open
@ns-cweber

Description

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /