From 4582d0695bda4337ccc22c0bb186c20649dd3e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 24 Nov 2022 15:29:52 +0100 Subject: [PATCH] Add build tags to make the project compatible with gopls (#470) The gopls deamon for text editor integrations used to complain about the `main()` function being redeclared across multiple `package main` files that share the same directory. This is because these individual scripts were meant to be run with `go run path/to/file.go` instead of being built as a binary. The latest gopls release supports recognizing files that are meant as individual runnable scripts, but they must be tagged with a build tag that makes them otherwise ignored. --- examples/countrylist.go | 2 ++ examples/cursor.go | 2 ++ examples/inputfilesuggestion.go | 2 ++ examples/longlist.go | 2 ++ examples/longmulti.go | 2 ++ examples/longmultikeepfilter.go | 2 ++ examples/map.go | 2 ++ examples/password.go | 2 ++ examples/select_description.go | 2 ++ examples/simple.go | 2 ++ examples/validation.go | 2 ++ tests/ask.go | 2 ++ tests/confirm.go | 4 +++- tests/doubleSelect.go | 2 ++ tests/editor.go | 4 +++- tests/help.go | 4 +++- tests/input.go | 2 ++ tests/longSelect.go | 2 ++ tests/multiselect.go | 2 ++ tests/password.go | 4 +++- tests/select.go | 4 +++- tests/selectThenInput.go | 2 ++ 22 files changed, 49 insertions(+), 5 deletions(-) diff --git a/examples/countrylist.go b/examples/countrylist.go index 9e0e4bc5..462a64d6 100644 --- a/examples/countrylist.go +++ b/examples/countrylist.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/cursor.go b/examples/cursor.go index fb8876cb..19e6b1ec 100644 --- a/examples/cursor.go +++ b/examples/cursor.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/inputfilesuggestion.go b/examples/inputfilesuggestion.go index 8872cc4d..3f5ccabe 100644 --- a/examples/inputfilesuggestion.go +++ b/examples/inputfilesuggestion.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/longlist.go b/examples/longlist.go index ce3e5784..14db5c05 100644 --- a/examples/longlist.go +++ b/examples/longlist.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/longmulti.go b/examples/longmulti.go index 985cb0f4..29595a2f 100644 --- a/examples/longmulti.go +++ b/examples/longmulti.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/longmultikeepfilter.go b/examples/longmultikeepfilter.go index 888e692b..13aecfa4 100644 --- a/examples/longmultikeepfilter.go +++ b/examples/longmultikeepfilter.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/map.go b/examples/map.go index 2f2aa339..c820c194 100644 --- a/examples/map.go +++ b/examples/map.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/password.go b/examples/password.go index 75c5e394..81492f6a 100644 --- a/examples/password.go +++ b/examples/password.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/select_description.go b/examples/select_description.go index bc1568ad..419229c9 100644 --- a/examples/select_description.go +++ b/examples/select_description.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/simple.go b/examples/simple.go index af5b0da9..1025fa4d 100644 --- a/examples/simple.go +++ b/examples/simple.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/examples/validation.go b/examples/validation.go index 24ba5b22..1ee90f3c 100644 --- a/examples/validation.go +++ b/examples/validation.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/tests/ask.go b/tests/ask.go index 7427d8bc..d1430d6a 100644 --- a/tests/ask.go +++ b/tests/ask.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/tests/confirm.go b/tests/confirm.go index fe2026db..b1192e67 100644 --- a/tests/confirm.go +++ b/tests/confirm.go @@ -1,8 +1,10 @@ +//go:build ignore + package main import ( "github.com/AlecAivazis/survey/v2" - "github.com/AlecAivazis/survey/v2/tests/util" + TestUtil "github.com/AlecAivazis/survey/v2/tests/util" ) var answer = false diff --git a/tests/doubleSelect.go b/tests/doubleSelect.go index c68d72d1..bc64d1cf 100644 --- a/tests/doubleSelect.go +++ b/tests/doubleSelect.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/tests/editor.go b/tests/editor.go index 287a319c..7b838668 100644 --- a/tests/editor.go +++ b/tests/editor.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( @@ -5,7 +7,7 @@ import ( "strings" "github.com/AlecAivazis/survey/v2" - "github.com/AlecAivazis/survey/v2/tests/util" + TestUtil "github.com/AlecAivazis/survey/v2/tests/util" ) var answer = "" diff --git a/tests/help.go b/tests/help.go index 917ca0f4..5f7ba5d0 100644 --- a/tests/help.go +++ b/tests/help.go @@ -1,8 +1,10 @@ +//go:build ignore + package main import ( "github.com/AlecAivazis/survey/v2" - "github.com/AlecAivazis/survey/v2/tests/util" + TestUtil "github.com/AlecAivazis/survey/v2/tests/util" ) var ( diff --git a/tests/input.go b/tests/input.go index 3558a099..9f4e35bd 100644 --- a/tests/input.go +++ b/tests/input.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/tests/longSelect.go b/tests/longSelect.go index 325681bf..d767a087 100644 --- a/tests/longSelect.go +++ b/tests/longSelect.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import "github.com/AlecAivazis/survey/v2" diff --git a/tests/multiselect.go b/tests/multiselect.go index cbed00c6..de8e9157 100644 --- a/tests/multiselect.go +++ b/tests/multiselect.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import ( diff --git a/tests/password.go b/tests/password.go index c5b33af1..5488ea31 100644 --- a/tests/password.go +++ b/tests/password.go @@ -1,8 +1,10 @@ +//go:build ignore + package main import ( "github.com/AlecAivazis/survey/v2" - "github.com/AlecAivazis/survey/v2/tests/util" + TestUtil "github.com/AlecAivazis/survey/v2/tests/util" ) var value = "" diff --git a/tests/select.go b/tests/select.go index 44c8253e..9ae28a78 100644 --- a/tests/select.go +++ b/tests/select.go @@ -1,8 +1,10 @@ +//go:build ignore + package main import ( "github.com/AlecAivazis/survey/v2" - "github.com/AlecAivazis/survey/v2/tests/util" + TestUtil "github.com/AlecAivazis/survey/v2/tests/util" ) var answer = "" diff --git a/tests/selectThenInput.go b/tests/selectThenInput.go index a8ba1196..35291f73 100644 --- a/tests/selectThenInput.go +++ b/tests/selectThenInput.go @@ -1,3 +1,5 @@ +//go:build ignore + package main import (