Go に startswith、endswith 関数はありませんか? 質問する

Go に startswith、endswith 関数はありませんか? 質問する

ただ知りたいのですが、Go プログラミング言語の標準ライブラリの一部として startswith、endswith などの標準関数がないのはなぜですか?

ベストアンサー1

文字列パッケージ内容プレフィックスありそして接尾辞あり

import "strings"

startsWith := strings.HasPrefix("prefix", "pre") // true
endsWith := strings.HasSuffix("suffix", "fix") // true

プレイ

おすすめ記事