8 ms·
Go Browser Package
- llmblockchain 2y ago"browser" seems like a terrible name. The correct name would be "useragent".
- deleted 2y ago[deleted]
- cebert 2y ago[Dupe] https://news.ycombinator.com/item?id=40402738 https://news.ycombinator.com/item?id=40402738
- richbell 2y agoThis submission was posted first. You can tell by the id.
- silisili 2y agoThis looks pretty useful, kudos. If I had any nit to make, it's about browser.NewBrowser. It stutters, and even with just New(), at first I thought it was making a client. Not sure what I'd go with, maybe Parse like net/url? Again, just a minor nit, not trying to take away what you've done here at all.
- kevindamm 2y agoPageReader? HtmlReader?
- dineshgowda24 2y agoYes, it does right. Honestly, I couldn't find a better name. `Parse` sounds nice, so let me think about it.
- dlopes7 2y agoJust a note, this was a bit difficult to read with the amount of times you repeat the phrase “ browser, device, platform, or bot that was making a request to the application”
- floobertoober 2y agoYeah - maybe "user agent"?
- dineshgowda24 2y agoYes, it makes sense. Thanks for the input. I have updated the documentation now.
- 38 2y agoplease stop doing stuff like this. its trivial to change the user-agent when making a request with a programming language, so any logic surrounding that should be non existent, or as simple as possible. the user-agent string has an essentially arbitrary format, so its not really a good place to be reading data from, or worse serving a different response based on the value.
- zuck_vs_musk 2y agoThis is useful. If you have a website, you want to collect statistical data on which browsers are accessing your website and test for the best experiences on the top browsers.
- 38 2y agothat sounds nice, but history has shown thats never what happens. what REALLY happens is the most popular browser and even version is determined, and anything thats not that doesn't get tested, and eventually breaks. its the pinnacle of lazy programming. "lets use telemetry so that we can point to data that allows us to make software thats as brittle as possible".
- philosopher1234 2y agoThere are limited resources in the world. The bulk of the resources should go to the bulk of the users. It’s a feature that rare configurations are less tested
- tgv 2y agoIt's a (minor) necessary evil that gives useful information. Almost no-one spoofs their user agent. I use this to pin down problems on the user side. Our users have all kinds of weird devices (e.g. browsing with a PlayStation) and it can be hard to find where things go wrong. There was a case where we lost more users than usual, and it turned out to be something very subtle related to tab switching in Safari. Without the user agent, we would never have found out.
- MOARDONGZPLZ 2y agoIs this just an ad?
- thangngoc89 2y agoI couldn’t understand what is the context of Browser until I read the first usage example with the line “Mozilla/5.0…”. I immediately understood that this is a user-agent parsing library. I would prefer user-agent which is a well understood term.
- jjice 2y agoI know there's a PHP package of the same name. I wouldn't be surprised if there were other packages of the same name and maybe it's just a namesake that continues.
- fastest963 2y agoWe use the uap-go (https://github.com/ua-parser/uap-go https://github.com/ua-parser/uap-go) package which parses the uap-core repo and has support for many more browsers.
- tgv 2y agoNot ideal. It is very slow. It takes 8 seconds for 3400 strings. That might be fine for occasional offline usage, but not for frequent usage, and certainly not for use in the backend (although I agree it should not be used there). I guess it matches all regexps against each string. It also misses some really common user agents, basically all iOS 11 and 12. They may be rare nowadays, but they still occur.
- mpcjanssen 2y agoIt seems to recompile every regex on every matching operation. This is really slow. The compiled regexes should be cached in the different matchers.
- dineshgowda24 2y agoGood point. I didn't give much attention to this part. I run some benchmarks and move these to compile only once. Thank you.
- dangcoderevue 2y ago[dead]
- kgeist 2y agoIt lists Sputnik as one of the supported browsers but it's a dead project once developed by the Russian government, and now it seems to be abandoned (last updates in 2021). I'd just delete any mentions of it.