Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soranoba/googp
googp is an OGP (Open Graph protocol) parser library for Golang.
https://github.com/soranoba/googp
golang ogp open-graph
Last synced: 3 months ago
JSON representation
googp is an OGP (Open Graph protocol) parser library for Golang.
- Host: GitHub
- URL: https://github.com/soranoba/googp
- Owner: soranoba
- License: apache-2.0
- Created: 2020-05-18T14:51:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-16T07:32:06.000Z (over 1 year ago)
- Last Synced: 2024-06-20T11:52:38.079Z (7 months ago)
- Topics: golang, ogp, open-graph
- Language: Go
- Homepage:
- Size: 39.1 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# googp
[![CircleCI](https://circleci.com/gh/soranoba/googp.svg?style=svg&circle-token=4282311988e7373cbc6033771566d912f1f446c9)](https://circleci.com/gh/soranoba/googp)
[![Go Report Card](https://goreportcard.com/badge/github.com/soranoba/googp)](https://goreportcard.com/report/github.com/soranoba/googp)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/soranoba/googp)](https://pkg.go.dev/github.com/soranoba/googp)googp is an [OGP (Open Graph protocol)](https://ogp.me/) parser library for Golang.
## Overviews
- 💯 Fully compliant with the reference
- 🔧 Highly customizable
- Available your own structs
- Available parsing your own OG Tags.
- 🙌 Supports type conversion
- Supports all types that implement [encoding.TextUnmarshaler](https://golang.org/pkg/encoding/#TextUnmarshaler).## Installation
To install it, run:
```bash
go get -u github.com/soranoba/googp
```## Usage
```go
import (
"fmt"
"github.com/soranoba/googp"
)type Music struct {
}type CustomOGP struct {
Title string `googp:"og:title"`
Description string `googp:"-"` // ignored
images []string // private field (ignored)
Videos []string `googp:"og:video,og:video:url"`
Musics Music `googp:"music"` // object type
}func main() {
var ogp1 googp.OGP
if err := googp.Fetch("https://soranoba.net", &ogp1); err != nil {
return
}
fmt.Println(ogp1)var ogp2 CustomOGP
if err := googp.Fetch("https://soranoba.net", &ogp2); err != nil {
return
}
fmt.Println(ogp2)
}
```## Object Mappings
### [Structured Properties](https://ogp.me/#structured)
```go
type OGP struct {
Image struct {
URL string `googp:"og:image,og:image:url"`
SecureURL string `googp:"og:image:secure_url"`
} `googp:"og:image"`
}
```You may collect in a struct by specifying the root tag.
In case of specifying `og:image`, googp collect values which property is `og:image:*`.### [Arrays](https://ogp.me/#array)
```go
type OGP struct {
Image []string `googp:"og:image"`
}
```googp collects values which the same properties.
### [Object Types](https://ogp.me/#types)
In googp, it same as Structured Properties.
You may define your own type yourself.