Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Add build tags to make the project compatible with gopls
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mislav committed Nov 23, 2022
1 parent b54ce38 commit 0164657
Show file tree
Hide file tree
Showing 23 changed files with 51 additions and 7 deletions.
2 changes: 2 additions & 0 deletions examples/countrylist.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/cursor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/inputfilesuggestion.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/longlist.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/longmulti.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/longmultikeepfilter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/map.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/password.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/select_description.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/simple.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/validation.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
4 changes: 2 additions & 2 deletions renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package survey
import (
"bytes"
"fmt"

"github.com/AlecAivazis/survey/v2/core"
"github.com/AlecAivazis/survey/v2/terminal"
"golang.org/x/term"
Expand Down Expand Up @@ -117,8 +118,7 @@ func (r *Renderer) RenderWithCursorOffset(tmpl string, data IterableOpts, opts [
}

// appendRenderedError appends text to the renderer's error buffer
// which is used to track what has been printed. It is not exported
// as errors should only be displayed via Error(config, error).
// which is used to track what has been printed.
func (r *Renderer) appendRenderedError(text string) {
r.renderedErrors.WriteString(text)
}
Expand Down
2 changes: 2 additions & 0 deletions tests/ask.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
4 changes: 3 additions & 1 deletion tests/confirm.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/doubleSelect.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
4 changes: 3 additions & 1 deletion tests/editor.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//go:build ignore

package main

import (
"fmt"
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/tests/util"
TestUtil "github.com/AlecAivazis/survey/v2/tests/util"
)

var answer = ""
Expand Down
4 changes: 3 additions & 1 deletion tests/help.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
2 changes: 2 additions & 0 deletions tests/input.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/longSelect.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import "github.com/AlecAivazis/survey/v2"
Expand Down
2 changes: 2 additions & 0 deletions tests/multiselect.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down
4 changes: 3 additions & 1 deletion tests/password.go
Original file line number Diff line number Diff line change
@@ -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 = ""
Expand Down
4 changes: 3 additions & 1 deletion tests/select.go
Original file line number Diff line number Diff line change
@@ -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 = ""
Expand Down
2 changes: 2 additions & 0 deletions tests/selectThenInput.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build ignore

package main

import (
Expand Down

0 comments on commit 0164657

Please sign in to comment.