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