Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

if fileFormat == "csv" || fileFormat == "xlsx" || fileFormat == "xls" {

    }

提示能简写,但是不知道怎么写


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

不在于怎么去简化,而是怎么去封装。比如可以写一个函数:

func InArray(value string, array []string) bool {
    // ...
    return true
}

GO没有太多语法糖,写代码都需要自己去提炼一些常用的工具函数


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...