doiutils

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package doiutils provides a set of functions to work with DOIs

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DOIResolver

func DOIResolver(doi string, sandbox bool) string

DOIResolver returns a DOI resolver for a given DOI

func DecodeDOI added in v0.6.28

func DecodeDOI(doi string) int64
Example
package main

import (
	"fmt"

	"github.com/front-matter/commonmeta/doiutils"
)

func main() {
	i := doiutils.DecodeDOI("https://doi.org/10.59350/v2gec-5xt36")
	fmt.Println(i)
}
Output:

930412369850

func EncodeDOI added in v0.6.28

func EncodeDOI(prefix string) string
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

func EscapeDOI(doi string) string

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 GetDOIRA

func GetDOIRA(doi string) (string, bool)

GetDOIRA returns the DOI registration agency for a given DOI or prefix

func IsRegisteredDOI added in v0.6.28

func IsRegisteredDOI(doi string) bool

IsRegisteredDOI checks if a DOI resolves (i.e. redirects) via the DOI handle servers

func IsRogueScholarDOI added in v0.2.14

func IsRogueScholarDOI(doi string, ra string) bool

IsRogueScholarDOI checks if a DOI is from Rogue Scholar

func NormalizeDOI

func NormalizeDOI(doi string) string

NormalizeDOI normalizes a DOI

func PrefixFromUrl

func PrefixFromUrl(str string) (string, error)

PrefixFromUrl extracts DOI prefix from URL

func ValidateDOI

func ValidateDOI(doi string) (string, bool)

ValidateDOI validates a DOI

func ValidatePrefix

func ValidatePrefix(doi string) (string, bool)

ValidatePrefix validates a DOI prefix for a given DOI

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL