Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mtlynch/social-go
A Go parser for various social media handles and URLs
https://github.com/mtlynch/social-go
Last synced: 24 days 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 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-11T00:34:13.000Z (about 2 years ago)
- Last Synced: 2024-06-21T19:55:20.979Z (5 months ago)
- Language: Go
- Size: 28.3 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# social-go
[![CircleCI](https://circleci.com/gh/mtlynch/social-go.svg?style=svg)](https://circleci.com/gh/mtlynch/social-go)
[![Go Reference](https://pkg.go.dev/badge/github.com/mtlynch/social-go/v2.svg)](https://pkg.go.dev/github.com/mtlynch/social-go/v2)
[![License](https://img.shields.io/badge/license-Unlicense-blue)](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
```