ANN -> Gomobiledetect - a lightweight package imported from PHP for detecting mobile devices including tablets.

Skip to first unread message

Shaked Klein Orbach

Feb 8, 2014, 9:08:49 PM2/8/14

I have imported the library Mobiledetect from PHP to Go together with my friend Carlos. 

The package, gomobiledetect is available and seems to be stable. At the moment there is one known minor bug which will be fixed as soon as possible. 

Feel free to use, report issues and contribute 


Tharaneedharan Vilwanathan

Feb 8, 2014, 10:53:25 PM2/8/14
to Shaked Klein Orbach, golang-nuts

Looks interesting. I will give it a try. Keep up the good work!


You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit


Jul 1, 2014, 2:00:00 PM7/1/14
Thanks! I am using it and it's fairly useful.  However, there is a performance problem before it is production ready. 

I did a pprof and found out the IsMobile() function is trying to match all the rules in matchDetectionRulesAgainstUA() function, and all the rules are just strings. And each rules are compiled to regular expression for each request! It's taking quite some CPUs. Better cache the compiled regular expressions.


Shaked Klein Orbach

Jul 2, 2014, 12:23:11 PM7/2/14
Hey Chris 

Thank you for helping and suggesting the above. 

I have created a new branch to support the cache which will allow you to or pre compile all the rules in advanced (using the method detect.PreCompileRegexRules()) or just to have a runtime cache (meaning only when the rule will be used it will be cached for next time) 

I have also started to work on some other important improvements such as replacing maps to lists and planning to handle a pool as you might find in the sync package
Besides, I am gonna be adding some more support to identify more devices\clients and hopefully the benchmark tests will be improved later on. 

Feel free to suggest more ideas, 

Thanks again!

Shaked Klein Orbach

Jul 5, 2014, 5:10:17 PM7/5/14
Hey again, 

I have done a lot of changes during the past few days. 

Most of my changes were merged to trunk and focused on replacing all maps to lists. 

You might notice that I have added new methods such as IsKey, VersionKey, VersionFloatKey. The main reason is because they work faster (see benchmarking). 

You are more than welcome to check the new version (0.2.1):

Beside that, as I have fixed most of the wrong code styling, I have decided to drop the "go" from gomobiledetect.

This is still in development and can be found at

I am considering to keep the reop's name the same so it will be clear that the repo represents mobile detection for go. 

What do you think? 


Shaked Klein Orbach

Aug 15, 2014, 12:42:07 PM8/15/14
Hey all 

I was waiting for a while and seems like there was no reply. 

Anyway I have deployed version 1.0.1 which also includes the package's name from gomobiledetect to mobiledetect. 

I was interested for an opinion regarding a change of the repository name as well... at the moment its The main reason I am asking is because its more clear to understand what the repository represents but it might conflict later with the import (although it doesn't seem like).

Happy to hear comments, ideas and of course any kind of contribution would be very appreciated. 

Reply all
Reply to author
0 new messages