GoMobileDetect is a lightweight package imported from PHP for detecting mobile devices including tablets.
The package is imported from MobileDetect which was originally written in PHP.
$ go get github.com/Shaked/gomobiledetect
- Now supports using
Http.Handler
implementation. See examples
- The package name had been changed to mobiledetect.
-
This version introduces a new method
IsKey(key int)
. This method is faster than theIs(key string)
. All keys can be found here -
The
Is(key string)
has been changed to support bothstring
andint
using theinterface{}
.
BenchmarkIsMobile 2000 1001884 ns/op
ok github.com/Shaked/gomobiledetect 7.091s
BenchmarkIsMobile 100000 19278 ns/op
ok github.com/Shaked/gomobiledetect 7.448s
There are different ways of using the package:
- Basic usage
- Basic router implementation
- Handler interface implementation
- Mux interface implementation
Go Mobile Detect is an open-source script released under MIT License.