Go test string contains substring

旧街凉风 提交于 2020-03-12 14:06:35

问题


How do I check if a string is a substring of another string in Go? For example, I want to check someString.contains("something").


回答1:


Use the function Contains from the strings package.

import {
    "strings"
}
strings.Contains("something", "some") // true


来源:https://stackoverflow.com/questions/45266784/go-test-string-contains-substring

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!