https://github.com/mtlynch/social-go
A Go parser for various social media handles and URLs
https://github.com/mtlynch/social-go
Last synced: 3 months ago
JSON representation
A Go parser for various social media handles and URLs
- Host: GitHub
- URL: https://github.com/mtlynch/social-go
- Owner: mtlynch
- License: unlicense
- Created: 2022-02-12T22:13:27.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-11T00:34:13.000Z (almost 3 years ago)
- Last Synced: 2025-04-10T01:55:10.670Z (3 months ago)
- Language: Go
- Size: 28.3 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# social-go
[](https://circleci.com/gh/mtlynch/social-go)
[](https://pkg.go.dev/github.com/mtlynch/social-go/v2)
[](LICENSE)A Go parser for various social media handles and URLs.
## Overview
social-go parses usernames from various social media platforms, verifying that the supplied username matches validity rules for that platform.
social-go's checks are local - they don't verify whether the account actually exists on the platform, just that it conforms to the platform's published schemas for usernames.
## Install
```bash
go get -u github.com/mtlynch/social-go/v2
``````golang
raw := "jack"
t1, _ := social.ParseTwitterHandle(raw)
fmt.Printf("%s -> %s\n", raw, t1)
// jack -> jackraw = "@jack"
t2, _ := social.ParseTwitterHandle(raw)
fmt.Printf("%s -> %s\n", raw, t2)
// @jack -> jackraw = "twitter.com/@jack"
t3, _ := social.ParseTwitterHandle(raw)
fmt.Printf("%s -> %s\n", raw, t3)
// twitter.com/@jack -> jack
``````golang
raw := "zuck"
fb, _ := social.ParseFacebookUsername(raw)
fmt.Printf("%s -> %s\n", raw, fb)
// zuck -> zuckraw = "https://facebook.com/zuck"
fb2, _ := social.ParseFacebookUsername(raw)
fmt.Printf("%s -> %s\n", raw, fb2)
// https://facebook.com/zuck -> zuck
``````golang
raw := "chelseahandler"
h1, _ := social.ParseInstagramHandle(raw)
fmt.Printf("%s -> %s\n", raw, h1)
// chelseahandler -> chelseahandlerraw = "@chelseahandler"
h2, _ := social.ParseInstagramHandle(raw)
fmt.Printf("%s -> %s\n", raw, h2)
// @chelseahandler -> chelseahandlerraw = "instagram.com/@chelseahandler"
h3, _ := social.ParseInstagramHandle(raw)
fmt.Printf("%s -> %s\n", raw, h3)
// instagram.com/@chelseahandler -> chelseahandler
```