iface: improved example

This commit is contained in:
2025-08-28 11:42:51 -04:00
parent 86f0b6c785
commit 7b40ec37be
3 changed files with 16 additions and 11 deletions

View File

@@ -1,11 +0,0 @@
package main
type Strummer interface {
Strum()
}
type Bocchi struct {
Guitar string
}
var _ Strummer = (*Bocchi)(nil)

3
iface/chord.go Normal file
View File

@@ -0,0 +1,3 @@
package main
type Chord string

13
iface/guitarist.go Normal file
View File

@@ -0,0 +1,13 @@
package main
type Guitarist interface {
Strum(chord Chord)
}
type Bocchi struct {
Guitar string
}
func (b *Bocchi) Strum(chord string) {}
var _ Guitarist = (*Bocchi)(nil)