Add String() implementations for some structs (#20)

This commit is contained in:
Don 2020-09-11 06:36:07 -07:00 committed by GitHub
parent be2c206c20
commit 5113109fd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 3 deletions

View File

@ -55,6 +55,10 @@ type (
} }
) )
func (c Commit) String() string {
return c.SHA
}
func (a Author) String() string { func (a Author) String() string {
return a.Username return a.Username
} }

View File

@ -37,3 +37,7 @@ type Repo struct {
// Private to show if the repo is private. // Private to show if the repo is private.
Private bool Private bool
} }
func (r Repo) String() string {
return r.Slug
}

View File

@ -37,3 +37,7 @@ type SemVer struct {
// Error is the semantic version parsing error if the tag was invalid. // Error is the semantic version parsing error if the tag was invalid.
Error string Error string
} }
func (s SemVer) String() string {
return s.Version
}

View File

@ -5,9 +5,7 @@
package drone package drone
import ( import "time"
"time"
)
// Stage represents a build stage. // Stage represents a build stage.
type Stage struct { type Stage struct {
@ -62,3 +60,7 @@ type Stage struct {
// DependsOn is a list of dependencies for the current build stage. // DependsOn is a list of dependencies for the current build stage.
DependsOn []string DependsOn []string
} }
func (s Stage) String() string {
return s.Name
}

View File

@ -13,3 +13,7 @@ type Step struct {
// Number is the numeric value of the step. // Number is the numeric value of the step.
Number int Number int
} }
func (s Step) String() string {
return s.Name
}

View File

@ -16,3 +16,7 @@ type System struct {
// Version for the system version. // Version for the system version.
Version string Version string
} }
func (s System) String() string {
return s.Host
}