https://github.com/seratch/go-slack-sdk-experimental
WIP: Experimental Slack SDK in Go
https://github.com/seratch/go-slack-sdk-experimental
Last synced: 9 months ago
JSON representation
WIP: Experimental Slack SDK in Go
- Host: GitHub
- URL: https://github.com/seratch/go-slack-sdk-experimental
- Owner: seratch
- License: mit
- Created: 2020-09-05T14:44:38.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2021-12-27T13:20:33.000Z (over 4 years ago)
- Last Synced: 2025-03-14T03:12:27.224Z (over 1 year ago)
- Language: Go
- Size: 2.55 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Experimental Slack SDK in Go
This is an experimental Slack API client library.
## Getting Started
### Start a New Project
```bash
go mod init example.com/hello-slack
go get github.com/seratch/go-slack-sdk-experimental/webapi
```
### Place `main.go`
```go
package main
import (
"encoding/json"
"fmt"
"github.com/seratch/go-slack-sdk-experimental/webapi"
"github.com/seratch/go-slack-sdk-experimental/webapi/chat_postMessage"
"io/ioutil"
"net/url"
"os"
)
func main() {
token := os.Getenv("SLACK_BOT_TOKEN")
client := webapi.NewClient(&token)
data := url.Values{}
data.Set("text", "Hi there!")
data.Set("channel", "#random")
resp, err := client.CallApi(chat_postMessage.ApiMethod, data)
if err != nil {
fmt.Println(fmt.Sprintf("HTTP error: %s", err))
return
}
bytes, _ := ioutil.ReadAll(resp.Body)
body, _ := chat_postMessage.UnmarshalChatPostMessage(bytes)
bytesAgain, _ := json.Marshal(body)
fmt.Println(string(bytesAgain))
if !*body.Ok {
fmt.Println(fmt.Sprintf("Slack error: %s", *body.Error))
}
}
```
### Run the App
```bash
export SLACK_BOT_TOKEN=xoxb-***
go run main.go
```
# License
The MIT License