https://github.com/reiver/go-fediverseid
Package fediverseid implements tools for working with Fediverse-IDs, for the Go programming language.
https://github.com/reiver/go-fediverseid
acct-uri activitypub activitystreams fediverse fediverse-id fediverseid mastodon social-web socialweb
Last synced: 7 months ago
JSON representation
Package fediverseid implements tools for working with Fediverse-IDs, for the Go programming language.
- Host: GitHub
- URL: https://github.com/reiver/go-fediverseid
- Owner: reiver
- License: mit
- Created: 2025-01-16T01:54:40.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-02-05T17:37:11.000Z (8 months ago)
- Last Synced: 2025-02-05T18:44:45.106Z (8 months ago)
- Topics: acct-uri, activitypub, activitystreams, fediverse, fediverse-id, fediverseid, mastodon, social-web, socialweb
- Language: Go
- Homepage:
- Size: 52.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-fediverseid
Package **fediverseid** implements tools for working with **Fediverse-ID**s, for the Go programming language.
**Fediverse-ID**s look like these:
* `@reiver@mastodon.social`
* `@joeblow@example.com`
* `@dariush@host.example`
* `@malekeh@host.example`## Documention
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-fediverseid
[](https://godoc.org/github.com/reiver/go-fediverseid)
## Origin
**Fediverse-ID** are derived from **Twitter-IDs**, such:
* `@reiver`
* `@twitter`
* `@golanggo`**Twitter-IDs** were **_not_** invented by the Twitter company.
Instead, users of Twitter started using them on Twitter as a way of replying to other people on Twitter.
The Twitter company noticed this, and then (the Twitter company) built this into Twitter.Twitter users started using **Twitter-IDs** because this convention of putting an at-symbol ("@") in front of someone's _handle_ to reply to them already existing on blogs, and web-based bulletin boards / forums.
Although on blogs, and web-based bulletin boards / forums, the `@handle` convention was often hyper-linked to the post that was being replied to.Some people try to trace a history for **Fediverse-ID**s to e-mail addresses — _these people are wrong_.
E-Mail addresses are compared to **Fediverse-ID**s as a way of helping people understand what **Fediverse-ID**s are.
The origin of the **Fediverse-ID**s does **_not_** go back to e-mail addresses — it instead goes back to Twitter, blogs, and web-based bulletin boards / forums.## Examples
To parse a Fediverse-ID and split it into its **name** and **host** you can do something similar to the following:
```golang
import "github.com/reiver/go-fediverseid"// ...
fediverseID, err := fediverseid.ParseFediverseID("@joeblow@host.example")
if nil != err {
fmt.Printf("ERROR: problem parsing fediverse-id: %s\n", err)
return
}name, found := fediverseID.Name()
if !found {
fmt.Println("ERROR: missing name")
return
}host, found := fediverseID.Host()
if !found {
fmt.Println("ERROR: missing host")
return
}
```And, to generate a Fediverse-ID from a **name** and a **host** you can do something similar to the following:
```golang
import "github.com/reiver/go-fediverseid"// ...
fid := fediverseid.CreateFediverseID("joeblow", "host.example")
var serializedFediverseID string = fediverseID.String()
```## Import
To import package **fediverseid** use `import` code like the following:
```
import "github.com/reiver/go-fediverseid"
```## Installation
To install package **fediverseid** do the following:
```
GOPROXY=direct go get github.com/reiver/go-fediverseid
```## Author
Package **fediverseid** was written by [Charles Iliya Krempeaux](http://reiver.link)