interfaceの使い方

Go言語のinterfaceの使い方についてまとめました。

動作環境

ホストOSWindows 10 21H1(19043.2130) 64bit
WSL2
Visual Studio Code1.70.2
Docker Desktop4.12.0(85629)
Go1.19.2

構文

type インターフェース名 interface {
  メソッド名 メソッドの戻り値の型
  ・
  ・
  ・
}

サンプル

.
├── go.mod
└── main.go