https://github.com/hslam/msg
Package msg provides a way to use System V message queues.
https://github.com/hslam/msg
go golang ipc message-queue msg msgget system-v unix
Last synced: 16 days ago
JSON representation
Package msg provides a way to use System V message queues.
- Host: GitHub
- URL: https://github.com/hslam/msg
- Owner: hslam
- License: mit
- Created: 2020-11-27T10:32:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-16T18:48:11.000Z (over 4 years ago)
- Last Synced: 2025-03-30T11:32:46.836Z (about 1 month ago)
- Topics: go, golang, ipc, message-queue, msg, msgget, system-v, unix
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# msg
[](https://pkg.go.dev/github.com/hslam/msg)
[](https://github.com/hslam/msg/actions)
[](https://goreportcard.com/report/github.com/hslam/msg)
[](https://github.com/hslam/msg/blob/master/LICENSE)Package msg provides a way to use System V message queues.
## Get started
### Install
```
go get github.com/hslam/msg
```
### Import
```
import "github.com/hslam/msg"
```
### Usage
#### Example
**msgsnd**
```go
package mainimport (
"github.com/hslam/ftok"
"github.com/hslam/msg"
"time"
)func main() {
key, err := ftok.Ftok("/tmp", 0x22)
if err != nil {
panic(err)
}
msgid, err := msg.Get(key, msg.IPC_CREAT|0600)
if err != nil {
panic(err)
}
defer msg.Remove(msgid)
err = msg.Send(msgid, 1, []byte("Hello World"), 0600)
if err != nil {
panic(err)
}
time.Sleep(time.Second * 10)
}
```
**msgrcv**
```go
package mainimport (
"fmt"
"github.com/hslam/ftok"
"github.com/hslam/msg"
)func main() {
key, err := ftok.Ftok("/tmp", 0x22)
if err != nil {
panic(err)
}
msgid, err := msg.Get(key, 0600)
if err != nil {
panic(err)
}
text, err := msg.Receive(msgid, 1, 0600)
if err != nil {
panic(err)
}
fmt.Println(string(text))
}
```#### Output
```
Hello World
```### License
This package is licensed under a MIT license (Copyright (c) 2020 Meng Huang)### Author
msg was written by Meng Huang.