Skip to content

Commit

Permalink
added some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
onattech committed Jan 14, 2023
1 parent e8c216b commit 0018c5d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (t *Tools) UploadFiles(r *http.Request, uploadDir string, rename ...bool) (
}
defer infile.Close()

// Buffer is to be used to check the first 512 bytes of the file to determine the file type
buff := make([]byte, 512)
_, err = infile.Read(buff)
if err != nil {
Expand All @@ -122,6 +123,7 @@ func (t *Tools) UploadFiles(r *http.Request, uploadDir string, rename ...bool) (
return nil, errors.New("the uploaded file type is not permitted")
}

// We had read the first 512 bytes above, now need to roll back to the beginning
_, err = infile.Seek(0, 0)
if err != nil {
return nil, err
Expand Down

2 comments on commit 0018c5d

@MYavuzYAGIS
Copy link

@MYavuzYAGIS MYavuzYAGIS commented on 0018c5d Feb 22, 2023

Choose a reason for hiding this comment

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

Overall nice project, I like tooling. I actually follow a coder, codes in go. Tomnomnom. His toolings is very nice as well and I use it frequently.

As for my comments:

pros:

nice test suite. πŸ’―
clean code. πŸ’―
good comments. πŸ’―

cons: ( a bit nit-picking here)

var names are not self explanatory, it gives hints ofc, but bit more explicit names would not hurt :)

Suggestions:

--> Why don't you add flag parser? It would be too good to have the following features:

--> Also a concise embedded man page. like toolkit --help || -h gives me flags and some use cases.

--> more self-explanatory readme. ( I believe it is cooking tho)

great repo πŸ‘πŸ»

@onattech
Copy link
Owner Author

Choose a reason for hiding this comment

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

Thank you for you comment my friend. I am glad you liked it.

I agree with you on variable naming. It is a GO thing. For some reason, convention is to keep the variable as short as possible. What is up with all the one letter variables? I don't like it but wanted to stick to the common convention.

I definitely want to add more features but always short on time. Prs are more than welcome. πŸ‘πŸΌ

Please sign in to comment.