go-swagger: swagger generate spec throws a lot of errors with golang 1.11

Problem statement

I install swagger from homebrew tap, then I run this command:

swagger generate spec -o ./assets/swagger.json -m

Now, I’m getting this error:

/usr/local/opt/go/libexec/src/internal/cpu/cpu_x86.go:9:7: CacheLineSize redeclared in this block
/usr/local/opt/go/libexec/src/internal/cpu/cpu_wasm.go:7:7: 	other declaration of CacheLineSize
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:14:6: Load redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:13:6: 	other declaration of Load
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:20:6: Loadp redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:19:6: 	other declaration of Loadp
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:26:6: Load64 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:25:6: 	other declaration of Load64
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:32:6: Xadd redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:30:6: 	other declaration of Xadd
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:40:6: Xadd64 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:33:6: 	other declaration of Xadd64
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:48:6: Xadduintptr redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:36:6: 	other declaration of Xadduintptr
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:56:6: Xchg redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:39:6: 	other declaration of Xchg
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:64:6: Xchg64 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:42:6: 	other declaration of Xchg64
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:72:6: Xchguintptr redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:45:6: 	other declaration of Xchguintptr
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:80:6: And8 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:48:6: 	other declaration of And8
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:86:6: Or8 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:51:6: 	other declaration of Or8
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:94:6: Cas64 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:56:6: 	other declaration of Cas64
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:104:6: Store redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:59:6: 	other declaration of Store
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:110:6: Store64 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:62:6: 	other declaration of Store64
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:116:6: StorepNoWB redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_amd64x.go:68:6: 	other declaration of StorepNoWB
/usr/local/opt/go/libexec/src/runtime/internal/atomic/stubs.go:12:6: Cas redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:122:6: 	other declaration of Cas
/usr/local/opt/go/libexec/src/runtime/internal/atomic/stubs.go:15:6: Casp1 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:132:6: 	other declaration of Casp1
/usr/local/opt/go/libexec/src/runtime/internal/atomic/stubs.go:18:6: Casuintptr redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:142:6: 	other declaration of Casuintptr
/usr/local/opt/go/libexec/src/runtime/internal/atomic/stubs.go:21:6: Storeuintptr redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:152:6: 	other declaration of Storeuintptr
/usr/local/opt/go/libexec/src/runtime/internal/atomic/stubs.go:24:6: Loaduintptr redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:158:6: 	other declaration of Loaduintptr
/usr/local/opt/go/libexec/src/runtime/internal/atomic/stubs.go:27:6: Loaduint redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:164:6: 	other declaration of Loaduint
/usr/local/opt/go/libexec/src/runtime/internal/atomic/stubs.go:32:6: Loadint64 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:170:6: 	other declaration of Loadint64
/usr/local/opt/go/libexec/src/runtime/internal/atomic/stubs.go:35:6: Xaddint64 redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/atomic/atomic_wasm.go:176:6: 	other declaration of Xaddint64
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:8:2: ArchFamily redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:8:2: 	other declaration of ArchFamily
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:9:2: BigEndian redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:9:2: 	other declaration of BigEndian
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:10:2: CacheLineSize redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:10:2: 	other declaration of CacheLineSize
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:11:2: DefaultPhysPageSize redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:11:2: 	other declaration of DefaultPhysPageSize
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:12:2: PCQuantum redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:12:2: 	other declaration of PCQuantum
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:13:2: Int64Align redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:13:2: 	other declaration of Int64Align
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:14:2: HugePageSize redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:14:2: 	other declaration of HugePageSize
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:15:2: MinFrameSize redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:15:2: 	other declaration of MinFrameSize
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_wasm.go:18:6: Uintreg redeclared in this block
/usr/local/opt/go/libexec/src/runtime/internal/sys/arch_amd64.go:18:6: 	other declaration of Uintreg
/usr/local/opt/go/libexec/src/runtime/sys_x86.go:16:6: gostartcall redeclared in this block
/usr/local/opt/go/libexec/src/runtime/sys_wasm.go:31:6: 	other declaration of gostartcall
couldn't load packages due to errors: internal/cpu, runtime/internal/sys, runtime and 1 more

Swagger specification

Steps to reproduce

Environment

swagger version: 0.16.0, commit: dd867fd63c30269ac217004c102f47a1774d4f5a go version: 1.11 OS: macos 10.13.6

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I met the same problem when i upgrade golang to 1.11.

outputs:

C:\go\src\internal\cpu\cpu_x86.go:9:7: CacheLineSize redeclared in this block
C:\go\src\internal\cpu\cpu_wasm.go:7:7:         other declaration of CacheLineSize
C:\go\src\runtime\internal\sys\arch_wasm.go:8:2: ArchFamily redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:8:2:       other declaration of ArchFamily
C:\go\src\runtime\internal\sys\arch_wasm.go:9:2: BigEndian redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:9:2:       other declaration of BigEndian
C:\go\src\runtime\internal\sys\arch_wasm.go:10:2: CacheLineSize redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:10:2:      other declaration of CacheLineSize
C:\go\src\runtime\internal\sys\arch_wasm.go:11:2: DefaultPhysPageSize redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:11:2:      other declaration of DefaultPhysPageSize
C:\go\src\runtime\internal\sys\arch_wasm.go:12:2: PCQuantum redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:12:2:      other declaration of PCQuantum
C:\go\src\runtime\internal\sys\arch_wasm.go:13:2: Int64Align redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:13:2:      other declaration of Int64Align
C:\go\src\runtime\internal\sys\arch_wasm.go:14:2: HugePageSize redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:14:2:      other declaration of HugePageSize
C:\go\src\runtime\internal\sys\arch_wasm.go:15:2: MinFrameSize redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:15:2:      other declaration of MinFrameSize
C:\go\src\runtime\internal\sys\arch_wasm.go:18:6: Uintreg redeclared in this block
C:\go\src\runtime\internal\sys\arch_amd64.go:18:6:      other declaration of Uintreg
C:\go\src\runtime\internal\atomic\atomic_wasm.go:14:6: Load redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:13:6:        other declaration of Load
C:\go\src\runtime\internal\atomic\atomic_wasm.go:20:6: Loadp redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:19:6:        other declaration of Loadp
C:\go\src\runtime\internal\atomic\atomic_wasm.go:26:6: Load64 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:25:6:        other declaration of Load64
C:\go\src\runtime\internal\atomic\atomic_wasm.go:32:6: Xadd redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:30:6:        other declaration of Xadd
C:\go\src\runtime\internal\atomic\atomic_wasm.go:40:6: Xadd64 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:33:6:        other declaration of Xadd64
C:\go\src\runtime\internal\atomic\atomic_wasm.go:48:6: Xadduintptr redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:36:6:        other declaration of Xadduintptr
C:\go\src\runtime\internal\atomic\atomic_wasm.go:56:6: Xchg redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:39:6:        other declaration of Xchg
C:\go\src\runtime\internal\atomic\atomic_wasm.go:64:6: Xchg64 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:42:6:        other declaration of Xchg64
C:\go\src\runtime\internal\atomic\atomic_wasm.go:72:6: Xchguintptr redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:45:6:        other declaration of Xchguintptr
C:\go\src\runtime\internal\atomic\atomic_wasm.go:80:6: And8 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:48:6:        other declaration of And8
C:\go\src\runtime\internal\atomic\atomic_wasm.go:86:6: Or8 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:51:6:        other declaration of Or8
C:\go\src\runtime\internal\atomic\atomic_wasm.go:94:6: Cas64 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:56:6:        other declaration of Cas64
C:\go\src\runtime\internal\atomic\atomic_wasm.go:104:6: Store redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:59:6:        other declaration of Store
C:\go\src\runtime\internal\atomic\atomic_wasm.go:110:6: Store64 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:62:6:        other declaration of Store64
C:\go\src\runtime\internal\atomic\atomic_wasm.go:116:6: StorepNoWB redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_amd64x.go:68:6:        other declaration of StorepNoWB
C:\go\src\runtime\internal\atomic\stubs.go:12:6: Cas redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_wasm.go:122:6:         other declaration of Cas
C:\go\src\runtime\internal\atomic\stubs.go:15:6: Casp1 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_wasm.go:132:6:         other declaration of Casp1
C:\go\src\runtime\internal\atomic\stubs.go:18:6: Casuintptr redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_wasm.go:142:6:         other declaration of Casuintptr
C:\go\src\runtime\internal\atomic\stubs.go:21:6: Storeuintptr redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_wasm.go:152:6:         other declaration of Storeuintptr
C:\go\src\runtime\internal\atomic\stubs.go:24:6: Loaduintptr redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_wasm.go:158:6:         other declaration of Loaduintptr
C:\go\src\runtime\internal\atomic\stubs.go:27:6: Loaduint redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_wasm.go:164:6:         other declaration of Loaduint
C:\go\src\runtime\internal\atomic\stubs.go:32:6: Loadint64 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_wasm.go:170:6:         other declaration of Loadint64
C:\go\src\runtime\internal\atomic\stubs.go:35:6: Xaddint64 redeclared in this block
C:\go\src\runtime\internal\atomic\atomic_wasm.go:176:6:         other declaration of Xaddint64
C:\go\src\runtime\sys_x86.go:16:6: gostartcall redeclared in this block
C:\go\src\runtime\sys_wasm.go:31:6:     other declaration of gostartcall
couldn't load packages due to errors: runtime/internal/atomic, runtime, runtime/internal/sys and 1 more

I think $GOPATH/pkg or %GOPATH%\pkg has binaries compiled with go 1.10 clear the folder and do a rebuild of your app you can also try with just doing go test -a ./... that would also rebuild and link your libs IIRC

Let me know if that fixes it. I don’t have an env to reproduce this in