This is a creation in Article, where the information may have evolved or changed.
Write in front
I am a golang programmer, and basically all of my stuff is developed with go. I recently wanted to give my personal site access to the search function, using the Swiftype tool. However, I found that it did not have a Golang API toolkit. On GitHub found a package, but found that a bug can not be used, so he fork the code to make a set.
Source Address: Https://github.com/mnhkahn/swiftype
Installation
go get -v gopkg.in/mnhkahn/swiftype.v1
Document
Documents can be viewed on godoc. Currently only support the search method, because my side also only use this, if the future my side of the different API requirements, will consider the update.
Type Client
- Func Newclientwithapikey (Api_key string, host string) *client
- Func Newclientwithusernamepassword (Username string, password string, host string) *client
- Func (c *client) engine (engine string) ([]byte, error)
- Func (c *client) Engines () ([]byte, error)
- Func (c Client) Search (engine string, query string) (Swiftyperesult, error)
Type Swiftyperesult
Example
SWIFTYPE := *swiftype.ClientSWIFTYPE_APIKEY := "YOUR OWN API KEY"SWIFTYPE_HOST := "api.swiftype.com"SWIFTYPE_ENGINE := "YOUR OWN ENGINE"SWIFTYPE := swiftype.NewClientWithApiKey(SWIFTYPE_APIKEY, SWIFTYPE_HOST)data, err := SWIFTYPE.Search(SWIFTYPE_ENGINE, q)if err != nil { panic(err)}_ = data