mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
8cb4eb1654
run semgrep-go ruleguard and semgrep scans https://github.com/dgryski/semgrep-go Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
32 lines
421 B
Go
32 lines
421 B
Go
package gio
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSafe(t *testing.T) {
|
|
chars := 30
|
|
|
|
var b bytes.Buffer
|
|
w := Safe(&b)
|
|
|
|
var wg sync.WaitGroup
|
|
wg.Add(chars)
|
|
for i := 0; i < chars; i++ {
|
|
go func() {
|
|
s, err := io.WriteString(w, "a")
|
|
require.Equal(t, 1, s)
|
|
require.NoError(t, err)
|
|
wg.Done()
|
|
}()
|
|
}
|
|
wg.Wait()
|
|
|
|
require.Len(t, b.String(), chars)
|
|
}
|