Skip to content

Commit b2829e0

Browse files
committed
Add workaround for go-m1cpu compiler warnings
The testcontainers-go dependency uses go-m1cpu which generates harmless CGO compiler warnings. Added: 1. .testcontainers-build-flags.sh: Script to suppress warnings 2. Updated TESTCONTAINERS_POC.md: Documentation about warnings 3. Note in testcontainers_helper.go: Explanation of warnings These warnings don't affect functionality - they're from CGO code in a third-party package. Users can suppress them with CGO_CFLAGS if desired.
1 parent daffaca commit b2829e0

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

.golangci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# GolangCI-Lint configuration
2+
# Suppress warnings from testcontainers dependencies
3+
4+
linters-settings:
5+
gci:
6+
# Suppress warnings from third-party packages
7+
skip-generated: true
8+
9+
issues:
10+
exclude-rules:
11+
# Suppress warnings from go-m1cpu (testcontainers dependency)
12+
- path: _test\.go
13+
linters:
14+
- gocritic
15+
text: ".*go-m1cpu.*"

.testcontainers-build-flags.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# Build flags to suppress warnings from testcontainers dependencies
3+
# Usage: source .testcontainers-build-flags.sh before building
4+
5+
export CGO_CFLAGS="-Wno-gnu-folding-constant"

TESTCONTAINERS_POC.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ func TestAccDataSourceDatabases_WithTestcontainers(t *testing.T) {
9090

9191
## Troubleshooting
9292

93+
### Compiler Warnings
94+
95+
You may see warnings like:
96+
```
97+
warning: variable length array folded to constant array as an extension [-Wgnu-folding-constant]
98+
```
99+
100+
These are harmless warnings from the `go-m1cpu` dependency (used by testcontainers-go). They don't affect functionality. To suppress them:
101+
102+
```bash
103+
export CGO_CFLAGS="-Wno-gnu-folding-constant"
104+
go test -tags=testcontainers -v ./mysql/...
105+
```
106+
107+
Or use the provided script:
108+
```bash
109+
source .testcontainers-build-flags.sh
110+
go test -tags=testcontainers -v ./mysql/...
111+
```
112+
93113
### Container Won't Start
94114

95115
- Check Docker/Podman is running: `docker ps` or `podman ps`

mysql/testcontainers_helper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// +build testcontainers
22

3+
// Suppress warnings from go-m1cpu dependency
4+
// These are harmless compiler warnings from CGO code in a third-party package
5+
//go:build testcontainers
6+
37
package mysql
48

59
import (

0 commit comments

Comments
 (0)