Skip to content

add extension checking#1

Open
fafato1 wants to merge 2 commits intocapythulhu:mainfrom
fafato1:main
Open

add extension checking#1
fafato1 wants to merge 2 commits intocapythulhu:mainfrom
fafato1:main

Conversation

@fafato1
Copy link
Copy Markdown

@fafato1 fafato1 commented Jul 16, 2022

No description provided.

@capythulhu
Copy link
Copy Markdown
Owner

Closing pull request due to inactivity

@capythulhu capythulhu closed this Jul 26, 2022
main.go Outdated
exten := filepath.Ext(os.Args[1])

if exten != ".bf" {
panic("Format not accept! " + exten)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, change this message to fit Go error messages pattern. Instead of indicating the wrong extension, which is clearly visible on the command line, inform the correct one. Also, make it all lower case. It could be something like "provided script must be a .bf file".

main.go Outdated
func main() {
p, err := os.ReadFile(os.Args[1])

exten := filepath.Ext(os.Args[1])
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this variable name to its shortest known abbreviation, in this case, it would probably be ext.

main.go Outdated
func main() {
p, err := os.ReadFile(os.Args[1])

exten := filepath.Ext(os.Args[1])
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File extension verification needs to occur after checking the file itself (line 70). That way, if the user inputs an invalid filepath (like "123"), it will not trigger an extension error, but a filepath error.

@capythulhu capythulhu reopened this Jul 30, 2022
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

Successfully merging this pull request may close these issues.

2 participants