mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
doc: Add and use LicenseYear
This commit is contained in:
parent
e2fd9b9e7e
commit
3264532004
@ -27,6 +27,8 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal"
|
||||
)
|
||||
|
||||
func execute(command string, args ...string) error {
|
||||
@ -55,12 +57,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
b, err := ioutil.ReadFile("../LICENSE")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
license := strings.TrimSpace(string(b))
|
||||
year, err := strconv.Atoi(regexp.MustCompile(`^Copyright (\d+)`).FindStringSubmatch(license)[1])
|
||||
year, err := internal.LicenseYear()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -17,7 +17,9 @@ package internal
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -33,3 +35,15 @@ func LicenseComment() (string, error) {
|
||||
license := "// " + strings.Join(lines[:len(lines)-1], "\n// ")
|
||||
return license, nil
|
||||
}
|
||||
|
||||
func LicenseYear() (int, error) {
|
||||
license, err := LicenseComment()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
year, err := strconv.Atoi(regexp.MustCompile(`^// Copyright (\d+)`).FindStringSubmatch(license)[1])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return year, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user