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

Realistic get ip method - faster locks #1

Merged
merged 1 commit into from
Apr 18, 2017

Conversation

esemplastic
Copy link
Contributor

Hello @johnathanhowell and welcome to Go.

Locks in go are performing better on small code-blocks than wrapped to a bigger one.
At these changes,

  • I changed the sync.Mutex to sync.RWMutex in order to lock/unlock per-read or read & write when ever we need it.
  • I also introduced a more realistic method to get an IP, even behind a regular proxy.
  • I commented the mu variable in order to be easy to understand what it locks/unlocks (it's a good practice to comment the lockers following by the variable(s) )

Hello @johnathanhowell and welcome to Go.

Locks in go are performing better on small code-blocks than wrapped to a bigger one. 
At these changes, 

- I changed the `sync.Mutex` to `sync.RWMutex` in order to lock/unlock per-read or read & write when ever we need it.
- I also introduced a more realistic method  to get an IP, even behind a regular proxy.
- I commented the `mu` variable in order to be easy to understand what it locks/unlocks (it's a good practice to comment the lockers following by the variable(s) )
@avahowell
Copy link
Owner

Thanks for the pull request!

@avahowell avahowell merged commit ba6fb5d into avahowell:master Apr 18, 2017
@esemplastic
Copy link
Contributor Author

You're welcome, continue this, it has many potentials and more features that we can adapt on it!

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