• Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Twitter like mentions and #hashtags parser for Go(Golang)

mention Build Status Coverage Status GoDoc

mention parses twitter like mentions and hashtags like @gernest and #Tanzania from text input.

Installation

go get github.com/gernest/mention

Usage

mention is flexible, meaning it is not only limited to @ and # tags. You can choose whatever tag you like and mention will take it from there.

twitter like mentions

For instance you have the following message

hello @gernesti I would like to follow you on twitter

And you want to know who was mentioned in the text.

package main

import (
	"fmt"
	"strings"

	"github.com/gernest/mention"
)

func main() {
	message := "hello @gernest I would like to follow you on twitter"

	tags := mention.GetTags('@', message)
	tagStrings := mention.GetTagsAsUniqueStrings('@', message)

	fmt.Println(tags)
	fmt.Println(tagStrings)
}

If you run the above example it will print [gernest] is the stdout.

twitter like hashtags

For instance you have the following message

how does it feel to be rejected? #loner

And you want to know the hashtags

package main

import (
	"fmt"
	"strings"

	"github.com/gernest/mention"
)

func main() {
	message := "how does it feel to be rejected? #loner"

	tags := mention.GetTags('#', message)

	fmt.Println(tags)
}

If you run the above example it will print [loner] in the stdout.

The API

mention exposes only one function GetTags(char rune, src string) []string

The first argument char is the prefix for your tag, this can be @ or # or whatever unicode character you prefer. Don't be worried by its type rune it is just your normal characters but in single quotes. See the examples for more information.

The second argument is the source of the input which can be from texts.

Contributing

Start with clicking the star button to make the author and his neighbors happy. Then fork the repository and submit a pull request for whatever change you want to be added to this project.

If you have any questions, just open an issue.

Author

Geofrey Ernest Twitter : @gernesti

Chad Barraford Github : @cbarraford

Licence

This project is released under the MIT licence. See LICENCE for more details.

More Repositories

1

utron

A lightweight MVC framework for Go(Golang)
Go
2,223
star
2

wow

😮❗❗ Wow❗ now my Go commandline app is spinning with 🌈 and 🐴
Go
507
star
3

hero

[NO LONGER MAINTAINED} oauth 2 server implementation in Go
Go
213
star
4

greact

like preact, but for go with wasm
Go
146
star
5

apidemic

Fake JSON response server
Go
136
star
6

alien

A lightweight and fast http router from outer space
Go
127
star
7

ita

Go(Golang) library that provides a clean API for dynamically calling structs methods
Go
70
star
8

hot

smart golang templates
Go
61
star
9

front

extracts frontmatter from text files with ease with golang.
Go
55
star
10

qlql

Go
26
star
11

bongo

Elegant static website generation with Go
Go
26
star
12

orange

A lightweight Object Relational Mapper for Go
Go
22
star
13

mailchecker-go

Temporary (disposable/throwaway) email detection library in Go(Golang)
Go
20
star
14

zedlist

DEPRECATED
Go
20
star
15

helen

Handle your static assets with care
Go
18
star
16

zunicode

Zig
17
star
17

hoodie

pure zig language server with swagger and bling bling
Zig
17
star
18

kemi

Win at unpacking archive files with Go (golang)
Go
16
star
19

aurora

minimalistic social network, with bolt database and Go
Go
15
star
20

resingo

[UNMAINTAINED] Unofficial golang sdk for resin.io
Go
14
star
21

time

Zig
14
star
22

talk

What I think
Go
13
star
23

cute

material-ui components for gopherjs and vecty
Go
13
star
24

nutz

A cool way to work with bolt database buckets
Go
12
star
25

vectypresent

Go
12
star
26

base32

base32 encoding/decoding for ziglang
Zig
11
star
27

requiemdb

Pure Go Permanent Storage For Open Telemetry Metrics, Traces and Logs, based on Compressed Roaring B-Tree Bitmaps, using Typescript as Query Language
Go
10
star
28

mpesa-dev-api

Developer guide for M-PESA API
9
star
29

blue

JSON to Influxdb line protocol
Go
9
star
30

awesome-africa

Curated list of awesome projects made in Africa
7
star
31

qlstore

gorilla/sessions storage with embedded sql database( (ql)
Go
6
star
32

url

Zig
6
star
33

semver

4
star
34

frieren

Alternative to prometheus for open telemetry data in (development | testing | staging ) environments built on Compressed Roaring Bitmaps
Go
4
star
35

goo

Win at Go(Golang) with Go
Go
3
star
36

tt

Go
3
star
37

mad

Go
3
star
38

qlfu

Go
3
star
39

lora

A simple website hosting application
CSS
2
star
40

mrs

A user profile manager, with boltdb
Go
2
star
41

wuxia

Go
2
star
42

sequel

Extensible SQL Lexer and Parser for Go
Go
2
star
43

arrow3

Build apache arrow records from protocol buffers
Go
2
star
44

rbf

Go
2
star
45

blogdown

view github based project wiki offline
Ruby
2
star
46

gforms

forms library for golang
Go
2
star
47

gs

Go
1
star
48

adapi

Personal advertisment management API service
Go
1
star
49

classnames

Port of classnames node module to gopherjs/vecty
Go
1
star
50

matrix

Go
1
star
51

glory

millitary grade amunition for your Go web development
Go
1
star
52

trib

Go
1
star
53

sweetjesus

Web backend for M-PESA processing
Go
1
star
54

tafuta

Go
1
star
55

zanzibar

An experimental build tool based oon Go templates.
Go
1
star
56

roaring

Go
1
star
57

rows

Go
1
star
58

jsonrpc2

Zig
1
star
59

image.zig

Image library for zig
Zig
1
star
60

pablo

Build and publish your book
Go
1
star
61

vscode-moon

TypeScript
1
star
62

wudl

Go
1
star
63

bearcub

Go
1
star
64

riddick

Pure Go .DS_Store file reader/writter
Go
1
star
65

legend

Legend of microservices
Go
1
star
66

laisense

Lincense inspector for Go(Golang) project
Go
1
star
67

lily.vim

vim syntax highlighting for lily programming language https://github.com/jesserayadkins/lily
Vim Script
1
star
68

go-wasm-server

JavaScript
1
star