doiutils

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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() {
	s := doiutils.DecodeDOI("https://doi.org/10.59350/v2gec-5xt36")
	fmt.Println(s)
}
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 GenerateDOIFromGUID added in v0.20.0

func GenerateDOIFromGUID(prefix string, guid string) string

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

func GenerateSubstackDOI(prefix string, guid string) string

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

func GenerateWordpressDOI(prefix string, slug string, guid string) string

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 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