Swiftype的Golang API 發布!

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

寫在前面

我是一個Golang程式員,基本上我所有的東西都是用Go開發的。前不久想給我的個人網站接入搜尋功能,使用了Swiftype這個工具。然而我發現它並沒有Golang的API工具包。在GitHub上面找了一個包,卻發現有bug不能用,遂自己fork了代碼搞一套。

源碼地址:https://github.com/mnhkahn/swiftype

安裝

go get -v gopkg.in/mnhkahn/swiftype.v1

文檔

文檔可以在godoc上面查看。目前只支援搜尋方法,因為我這邊也只用這個,如果未來我這邊有別的API需求,會考慮更新。

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

例子

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

原文連結:Swiftype的Golang API 發布!,轉載請註明來源!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.