From db26b38e123cd2da0567992ca7795e23e92c8bab Mon Sep 17 00:00:00 2001
From: Rui Chen <rui@chenrui.dev>
Date: Wed, 3 Aug 2022 12:01:40 -0400
Subject: [PATCH 1/5] deps: update to use go1.19

Signed-off-by: Rui Chen <rui@chenrui.dev>
---
 .github/workflows/build.yml      | 2 +-
 .github/workflows/e2e.yml        | 2 +-
 .github/workflows/generate.yml   | 2 +-
 .github/workflows/goreleaser.yml | 2 +-
 .github/workflows/lint.yml       | 2 +-
 .github/workflows/release.yml    | 2 +-
 Dockerfile                       | 2 +-
 docs/developer-guide/building.md | 2 +-
 go.mod                           | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0a7f0acfc..7fb1ae7db 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -25,7 +25,7 @@ jobs:
     - name: Set up Go
       uses: actions/setup-go@v3
       with:
-        go-version: 1.18
+        go-version: 1.19
     - id: cache-paths
       name: Get cache paths
       run: |
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index c552305fc..c27ff55e8 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -25,7 +25,7 @@ jobs:
     - name: Set up Go
       uses: actions/setup-go@v3
       with:
-        go-version: 1.18
+        go-version: 1.19
     - id: cache-paths
       name: Get cache paths
       run: |
diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml
index 0bfce3af0..a18b9b9af 100644
--- a/.github/workflows/generate.yml
+++ b/.github/workflows/generate.yml
@@ -13,7 +13,7 @@ jobs:
     - name: Set up Go
       uses: actions/setup-go@v3
       with:
-        go-version: 1.18
+        go-version: 1.19
     - id: cache-paths
       name: Get cache paths
       run: |
diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml
index 824021f65..95dbf8b12 100644
--- a/.github/workflows/goreleaser.yml
+++ b/.github/workflows/goreleaser.yml
@@ -19,7 +19,7 @@ jobs:
     - name: Set up Go
       uses: actions/setup-go@v3
       with:
-        go-version: 1.18
+        go-version: 1.19
     - name: goreleaser check
       uses: goreleaser/goreleaser-action@v3
       with:
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index b0ee000fc..a15073cbf 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -19,7 +19,7 @@ jobs:
     - name: Set up Go
       uses: actions/setup-go@v3
       with:
-        go-version: 1.18
+        go-version: 1.19
     - name: Run linters
       uses: golangci/golangci-lint-action@v3.2.0
       with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 038474fe8..367a620c8 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -22,7 +22,7 @@ jobs:
     - name: Set up Go
       uses: actions/setup-go@v3
       with:
-        go-version: 1.18
+        go-version: 1.19
     - name: Install Cosign
       uses: sigstore/cosign-installer@v2.5.0
       with:
diff --git a/Dockerfile b/Dockerfile
index a2aa4eb80..a72290cb6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM golang:1.18.4-alpine3.15 as builder
+FROM golang:1.19-alpine3.16 as builder
 
 RUN apk add --no-cache make
 
diff --git a/docs/developer-guide/building.md b/docs/developer-guide/building.md
index 9cb06edf4..c91ed31d8 100644
--- a/docs/developer-guide/building.md
+++ b/docs/developer-guide/building.md
@@ -1,6 +1,6 @@
 # Building TFLint
 
-Go 1.18 or higher is required to build TFLint from source code. Clone the source code and run the `make` command. Built binary will be placed in `dist` directory.
+Go 1.19 or higher is required to build TFLint from source code. Clone the source code and run the `make` command. Built binary will be placed in `dist` directory.
 
 ```console
 $ git clone https://github.com/terraform-linters/tflint.git
diff --git a/go.mod b/go.mod
index e1ca379b7..42e07ebda 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/terraform-linters/tflint
 
-go 1.18
+go 1.19
 
 require (
 	github.com/Masterminds/semver/v3 v3.1.1

From 5aff7461328e077553af3fd348c8bbeee6d6d672 Mon Sep 17 00:00:00 2001
From: Rui Chen <rui@chenrui.dev>
Date: Fri, 5 Aug 2022 00:13:48 -0400
Subject: [PATCH 2/5] run `golangci-lint run --fix`

---
 plugin/checksum.go  |  1 -
 plugin/discovery.go |  8 ++++----
 plugin/install.go   |  1 -
 tflint/runner.go    | 14 +++++++-------
 4 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/plugin/checksum.go b/plugin/checksum.go
index 5f7fe1d8b..905a6911b 100644
--- a/plugin/checksum.go
+++ b/plugin/checksum.go
@@ -22,7 +22,6 @@ type Checksummer struct {
 // 3a61fff3689f27c89bce22893219919c629d2e10b96e7eadd5fef9f0e90bb353  tflint-ruleset-aws_darwin_amd64.zip
 // 482419fdeed00692304e59558b5b0d915d4727868b88a5adbbbb76f5ed1b537a  tflint-ruleset-aws_linux_amd64.zip
 // db4eed4c0abcfb0b851da5bbfe8d0c71e1c2b6afe4fd627638a462c655045902  tflint-ruleset-aws_windows_amd64.zip
-//
 func NewChecksummer(f io.Reader) (*Checksummer, error) {
 	scanner := bufio.NewScanner(f)
 
diff --git a/plugin/discovery.go b/plugin/discovery.go
index d5a44a871..dd2b19cbb 100644
--- a/plugin/discovery.go
+++ b/plugin/discovery.go
@@ -83,10 +83,10 @@ func FindPluginPath(config *InstallConfig) (string, error) {
 // getPluginDir returns the base plugin directory.
 // Adopted with the following priorities:
 //
-//   1. `plugin_dir` in a global config
-//   2. `TFLINT_PLUGIN_DIR` environment variable
-//   3. Current directory (./.tflint.d/plugins)
-//   4. Home directory (~/.tflint.d/plugins)
+//  1. `plugin_dir` in a global config
+//  2. `TFLINT_PLUGIN_DIR` environment variable
+//  3. Current directory (./.tflint.d/plugins)
+//  4. Home directory (~/.tflint.d/plugins)
 //
 // If the environment variable is set, other directories will not be considered,
 // but if the current directory does not exist, it will fallback to the home directory.
diff --git a/plugin/install.go b/plugin/install.go
index b20c1c1b6..1a1944aee 100644
--- a/plugin/install.go
+++ b/plugin/install.go
@@ -71,7 +71,6 @@ func (c *InstallConfig) AssetName() string {
 //
 //   - The release must contain a signature file for the checksum file with the name checksums.txt.sig
 //   - The signature file must be binary OpenPGP format
-//
 func (c *InstallConfig) Install() (string, error) {
 	dir, err := getPluginDir(c.globalConfig)
 	if err != nil {
diff --git a/tflint/runner.go b/tflint/runner.go
index e7e7b1d02..63fa05060 100644
--- a/tflint/runner.go
+++ b/tflint/runner.go
@@ -215,13 +215,13 @@ func NewModuleRunners(parent *Runner) ([]*Runner, error) {
 // Basically, this function is a wrapper for hclext.PartialContent, but in some ways it reproduces
 // Terraform language semantics.
 //
-//   1. The block schema implicitly adds dynamic blocks to the target
-//      https://www.terraform.io/language/expressions/dynamic-blocks
-//   2. Supports overriding files
-//      https://www.terraform.io/language/files/override
-//   3. Resources not created by count or for_each will be ignored
-//      https://www.terraform.io/language/meta-arguments/count
-//      https://www.terraform.io/language/meta-arguments/for_each
+//  1. The block schema implicitly adds dynamic blocks to the target
+//     https://www.terraform.io/language/expressions/dynamic-blocks
+//  2. Supports overriding files
+//     https://www.terraform.io/language/files/override
+//  3. Resources not created by count or for_each will be ignored
+//     https://www.terraform.io/language/meta-arguments/count
+//     https://www.terraform.io/language/meta-arguments/for_each
 //
 // However, this behavior is controlled by options. The above is the default.
 func (r *Runner) GetModuleContent(bodyS *hclext.BodySchema, opts sdk.GetModuleContentOption) (*hclext.BodyContent, hcl.Diagnostics) {

From 2b0c7455b2d809ce7a5e5990543318bcd4258bd1 Mon Sep 17 00:00:00 2001
From: Rui Chen <rui@chenrui.dev>
Date: Fri, 5 Aug 2022 00:35:49 -0400
Subject: [PATCH 3/5] fix golangci-lint issues

Signed-off-by: Rui Chen <rui@chenrui.dev>
---
 cmd/langserver.go                                | 3 +--
 langserver/handler.go                            | 6 +++---
 langserver/text_document_did_change.go           | 2 +-
 langserver/text_document_did_open.go             | 2 +-
 langserver/workspace_did_change_watched_files.go | 2 +-
 rules/terraformrules/utils.go                    | 6 ------
 6 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/cmd/langserver.go b/cmd/langserver.go
index 7d3877098..a9b1dfb53 100644
--- a/cmd/langserver.go
+++ b/cmd/langserver.go
@@ -2,7 +2,6 @@ package cmd
 
 import (
 	"context"
-	"fmt"
 	"log"
 	"os"
 
@@ -16,7 +15,7 @@ func (cli *CLI) startLanguageServer(configPath string, cliConfig *tflint.Config)
 
 	handler, plugin, err := langserver.NewHandler(configPath, cliConfig)
 	if err != nil {
-		log.Println(fmt.Sprintf("Failed to start language server: %s", err))
+		log.Printf("Failed to start language server: %s", err)
 		return ExitCodeError
 	}
 	if plugin != nil {
diff --git a/langserver/handler.go b/langserver/handler.go
index aa0e7a787..cd8e65be2 100644
--- a/langserver/handler.go
+++ b/langserver/handler.go
@@ -80,9 +80,9 @@ func (h *handler) handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2
 				Data:    req.Params,
 			}
 		}
-		log.Println(fmt.Sprintf("Received `%s` with `%s`", req.Method, string(params)))
+		log.Printf("Received `%s` with `%s`", req.Method, string(params))
 	} else {
-		log.Println(fmt.Sprintf("Received `%s`", req.Method))
+		log.Printf("Received `%s`", req.Method)
 	}
 
 	if h.shutdown && req.Method != "exit" {
@@ -120,7 +120,7 @@ func (h *handler) handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2
 
 func (h *handler) chdir(dir string) error {
 	if h.rootDir != dir {
-		log.Println(fmt.Sprintf("Changing directory: %s", dir))
+		log.Printf("Changing directory: %s", dir)
 		if err := os.Chdir(dir); err != nil {
 			return fmt.Errorf("Failed to chdir to %s: %s", dir, err)
 		}
diff --git a/langserver/text_document_did_change.go b/langserver/text_document_did_change.go
index 1f1b6c08c..a44fb2293 100644
--- a/langserver/text_document_did_change.go
+++ b/langserver/text_document_did_change.go
@@ -50,7 +50,7 @@ func (h *handler) textDocumentDidChange(ctx context.Context, conn *jsonrpc2.Conn
 		return nil, err
 	}
 
-	log.Println(fmt.Sprintf("Notify `textDocument/publishDiagnostics` with `%#v`", diagnostics))
+	log.Printf("Notify `textDocument/publishDiagnostics` with `%#v`", diagnostics)
 	for path, diags := range diagnostics {
 		err = conn.Notify(
 			ctx,
diff --git a/langserver/text_document_did_open.go b/langserver/text_document_did_open.go
index 550caebb9..d35851925 100644
--- a/langserver/text_document_did_open.go
+++ b/langserver/text_document_did_open.go
@@ -48,7 +48,7 @@ func (h *handler) textDocumentDidOpen(ctx context.Context, conn *jsonrpc2.Conn,
 		return nil, err
 	}
 
-	log.Println(fmt.Sprintf("Notify `textDocument/publishDiagnostics` with `%#v`", diagnostics))
+	log.Printf("Notify `textDocument/publishDiagnostics` with `%#v`", diagnostics)
 	for path, diags := range diagnostics {
 		err = conn.Notify(
 			ctx,
diff --git a/langserver/workspace_did_change_watched_files.go b/langserver/workspace_did_change_watched_files.go
index 5fd6531a0..fab5ce61f 100644
--- a/langserver/workspace_did_change_watched_files.go
+++ b/langserver/workspace_did_change_watched_files.go
@@ -32,7 +32,7 @@ func (h *handler) workspaceDidChangeWatchedFiles(ctx context.Context, conn *json
 		return nil, err
 	}
 
-	log.Println(fmt.Sprintf("Notify `textDocument/publishDiagnostics` with `%#v`", diagnostics))
+	log.Printf("Notify `textDocument/publishDiagnostics` with `%#v`", diagnostics)
 	for path, diags := range diagnostics {
 		err = conn.Notify(
 			ctx,
diff --git a/rules/terraformrules/utils.go b/rules/terraformrules/utils.go
index 71164926d..de89ccb77 100644
--- a/rules/terraformrules/utils.go
+++ b/rules/terraformrules/utils.go
@@ -235,12 +235,6 @@ type referencable interface {
 	referenceableSigil()
 }
 
-type referenceable struct {
-}
-
-func (r referenceable) referenceableSigil() {
-}
-
 type inputVariableReference struct {
 	referencable
 	name string

From a0f3dec3a9b1f26466e44246c05b7edf1b5f20f5 Mon Sep 17 00:00:00 2001
From: Rui Chen <rui@chenrui.dev>
Date: Fri, 5 Aug 2022 00:38:09 -0400
Subject: [PATCH 4/5] update golangci-lint ot 1.48.0

Signed-off-by: Rui Chen <rui@chenrui.dev>
---
 .github/workflows/lint.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index a15073cbf..df7b7cc27 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -23,4 +23,4 @@ jobs:
     - name: Run linters
       uses: golangci/golangci-lint-action@v3.2.0
       with:
-        version: v1.45
+        version: v1.48.0

From 87c8a223056d269558ce7e6e093646cf6f665c58 Mon Sep 17 00:00:00 2001
From: Rui Chen <rui@chenrui.dev>
Date: Fri, 5 Aug 2022 00:39:45 -0400
Subject: [PATCH 5/5] update to ~1.48 for golangci-lint

Signed-off-by: Rui Chen <rui@chenrui.dev>
---
 .github/workflows/lint.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index df7b7cc27..b4a69543f 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -23,4 +23,4 @@ jobs:
     - name: Run linters
       uses: golangci/golangci-lint-action@v3.2.0
       with:
-        version: v1.48.0
+        version: v1.48