-
Notifications
You must be signed in to change notification settings - Fork 0
/
source.go
79 lines (55 loc) · 2.21 KB
/
source.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package source
import (
"strings"
"github.com/coffeebeats/gdenv/pkg/godot/artifact"
"github.com/coffeebeats/gdenv/pkg/godot/artifact/archive"
"github.com/coffeebeats/gdenv/pkg/godot/version"
)
const (
namePrefix = "godot"
nameSeparator = "-"
)
type Archive = archive.TarXZ[Source]
/* -------------------------------------------------------------------------- */
/* Struct: Source */
/* -------------------------------------------------------------------------- */
// An 'Artifact' representing Godot source code for a specific version.
type Source struct {
version version.Version
}
// Compile-time verifications that 'Source' implements 'Artifact'.
var _ artifact.Artifact = (*Source)(nil)
/* ------------------------------ Function: New ----------------------------- */
// Creates a new 'Source' for the specified 'Version'.
func New(v version.Version) Source {
return Source{v}
}
/* ------------------------ Impl: archive.Archivable ------------------------ */
// Allows 'Source' to be used by 'Archive' implementation.
func (s Source) Archivable() {}
/* ------------------------- Impl: artifact.Artifact ------------------------ */
// Artifact "registers" 'Source' as a Godot release artifact.
func (s Source) Artifact() {}
/* -------------------------- Impl: artifact.Named -------------------------- */
// Returns the name of the Godot source directory for the specified 'Version'.
//
// NOTE: Godot names its executables in the format 'godot-<VERSION>'.
func (s Source) Name() string {
var name strings.Builder
name.WriteString(namePrefix)
name.WriteString(nameSeparator)
name.WriteString(strings.TrimPrefix(s.version.String(), version.Prefix))
return name.String()
}
/* ------------------------ Impl: artifact.Versioned ------------------------ */
func (s Source) Version() version.Version {
return s.version
}
/* ----------------------- Impl: checksum.Checksumable ---------------------- */
// Checksumable "registers" 'Source' as a Godot release artifact with published
// file checksums.
func (s Source) Checksumable() {}
/* ----------------------------- Impl: Stringer ----------------------------- */
func (s Source) String() string {
return s.Name()
}