refactor: create Plain method
parent
981b9721ed
commit
0971563ddd
10
google.go
10
google.go
|
@ -108,8 +108,8 @@ func (e *GoogleSearch) Ext(ext string) *GoogleSearch {
|
|||
}
|
||||
|
||||
// Exclude excludes some results.
|
||||
func (e *GoogleSearch) Exclude(value string) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.concat(excludeTag, value, false))
|
||||
func (e *GoogleSearch) Exclude(tags *GoogleSearch) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.concat(excludeTag, tags.String(), false))
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -124,3 +124,9 @@ func (e *GoogleSearch) Intitle(value string) *GoogleSearch {
|
|||
e.tags = append(e.tags, e.concat(intitleTag, value, true))
|
||||
return e
|
||||
}
|
||||
|
||||
// Plain allows you to add additional values as string without any kind of formatting.
|
||||
func (e *GoogleSearch) Plain(value string) *GoogleSearch {
|
||||
e.tags = append(e.tags, value)
|
||||
return e
|
||||
}
|
||||
|
|
|
@ -105,10 +105,10 @@ func TestInit(t *testing.T) {
|
|||
dork = NewGoogleSearch()
|
||||
|
||||
result := dork.
|
||||
Exclude("html").
|
||||
Exclude("htm").
|
||||
Exclude("php").
|
||||
Exclude("md5sums").
|
||||
Exclude(NewGoogleSearch().Plain("html")).
|
||||
Exclude(NewGoogleSearch().Plain("htm")).
|
||||
Exclude(NewGoogleSearch().Plain("php")).
|
||||
Exclude(NewGoogleSearch().Plain("md5sums")).
|
||||
String()
|
||||
|
||||
assert.Equal(result, "-html -htm -php -md5sums", "they should be equal")
|
||||
|
|
Loading…
Reference in New Issue