Documentation
¶
Overview ¶
Package doiutils provides a set of functions to work with DOIs
Index ¶
- func DOIResolver(doi string, sandbox bool) string
- func DecodeDOI(doi string) int64
- func EncodeDOI(prefix string) string
- func EscapeDOI(doi string) string
- func GenerateDOIFromGUID(prefix string, guid string) string
- func GenerateSubstackDOI(prefix string, guid string) string
- func GenerateWordpressDOI(prefix string, slug string, guid string) string
- func GetDOIRA(doi string) (string, bool)
- func IsRegisteredDOI(doi string) bool
- func IsRogueScholarDOI(doi string, ra string) bool
- func NormalizeDOI(doi string) string
- func PrefixFromUrl(str string) (string, error)
- func ValidateDOI(doi string) (string, bool)
- func ValidatePrefix(doi string) (string, bool)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DOIResolver ¶
DOIResolver returns a DOI resolver for a given DOI
func DecodeDOI ¶ added in v0.6.28
Example ¶
package main
import (
"fmt"
"github.com/front-matter/commonmeta/doiutils"
)
func main() {
s := doiutils.DecodeDOI("https://doi.org/10.59350/v2gec-5xt36")
fmt.Println(s)
}
Output: 930412369850
func EncodeDOI ¶ added in v0.6.28
Example ¶
package main
import (
"fmt"
"regexp"
"github.com/front-matter/commonmeta/doiutils"
)
func main() {
s := doiutils.EncodeDOI("10.73731")
r := regexp.MustCompile(`^https://doi.org/10.73731/(.+)$`)
fmt.Println(r.MatchString(s))
}
Output: true
func EscapeDOI ¶ added in v0.5.27
EscapeDOI escapes a DOI, i.e. replaces '/' with '%2F'
Example ¶
package main
import (
"fmt"
"github.com/front-matter/commonmeta/doiutils"
)
func main() {
s := doiutils.EscapeDOI("10.59350/k0746-rsc44")
fmt.Println(s)
}
Output: 10.59350%2Fk0746-rsc44
func GenerateDOIFromGUID ¶ added in v0.20.0
GenerateDOIFromGUID validates a GUID that is a DOI
Example ¶
package main
import (
"fmt"
"github.com/front-matter/commonmeta/doiutils"
)
func main() {
s := doiutils.GenerateDOIFromGUID("10.59350", "https://doi.org/10.59350/v2gec-5xt36")
fmt.Println(s)
}
Output: https://doi.org/10.59350/v2gec-5xt36
func GenerateSubstackDOI ¶ added in v0.20.1
GenerateSubstackDOI generates a DOI from a Substack GUID
Example ¶
package main
import (
"fmt"
"github.com/front-matter/commonmeta/doiutils"
)
func main() {
s := doiutils.GenerateSubstackDOI("10.59350", "161006169")
fmt.Println(s)
}
Output: https://doi.org/10.59350/4shg-js75
func GenerateWordpressDOI ¶ added in v0.20.0
GenerateWordpressDOI generates a DOI from a Wordpress GUID and slug
Example ¶
package main
import (
"fmt"
"github.com/front-matter/commonmeta/doiutils"
)
func main() {
s := doiutils.GenerateWordpressDOI("10.59350", "svpow", "https://svpow.com/?p=23496")
fmt.Println(s)
}
Output: https://doi.org/10.59350/svpow.23496
func IsRegisteredDOI ¶ added in v0.6.28
IsRegisteredDOI checks if a DOI resolves (i.e. redirects) via the DOI handle servers
func IsRogueScholarDOI ¶ added in v0.2.14
IsRogueScholarDOI checks if a DOI is from Rogue Scholar
func PrefixFromUrl ¶
PrefixFromUrl extracts DOI prefix from URL
func ValidatePrefix ¶
ValidatePrefix validates a DOI prefix for a given DOI
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.