You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
atgo feature add zero --file zero.go
# 他のfeatureを参照する場合
atgo feature add max --file max.go --use zero
feature間の参照は後付けでも良いかも
max.go
package main
import (
"golang.org/x/exp/constraints"
)
// max returns the max value in s.funcmax[T constraints.Ordered](s...T) T {
switchlen(s) {
case0:
returnzero[T]()
case1:
returns[0]
}
m:=s[0]
for_, v:=ranges[1:] {
ifv>m {
m=v
}
}
returnm
}
zero.go
package main
import (
"golang.org/x/exp/constraints"
)
// zero returns the zero value of T.funczero[Tany]() T {
varzeroTreturnzero
}
個別の実装を事前に定義して任意にmain.goに取り込める機能の追加
例(イメージ)
featureの登録
以下のコマンドでfeatureとして扱うパーツを登録する。
一旦登録するところを優先するけど、いずれはコンパイルチェックもできるようにしたい
atgo feature add zero --file zero.go # 他のfeatureを参照する場合 atgo feature add max --file max.go --use zero
feature間の参照は後付けでも良いかも
featureの利用
とすると、main.go に max.go とそこから参照される zero.go の内容が追加される
この時に
The text was updated successfully, but these errors were encountered: