I am trying out following sample snippet to run on my vscode editor
below is a snippen which i think is problematic. Vscode does point to some error but maybe I am missing that.
app.go
package main
import {
"database/sql"
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
_ "github.com/lib/pq"
}
type App struct {
Router *mux.Router
DB *sql.DB
}
//init and other functions here
model.go
package main
type product struct {
ID int `json:"id"`
Name string `json:"name"`
Price float64 `json:"price"`
}
//some code below
When I try to run vscode debugger with above given settings, it gives me below errors:
can't load package: package .:
app.go:3:8: expected 'STRING', found '{'
app.go:4:2: expected ';', found 'STRING' "database/sql"
exit status 1
Process exiting with code: 1
I am not able to debug as this is very vague to me and I have tried looking for it on other forums. Would be greatful if someone can help with what to do with the above error.
The import block is supposed to be surrounded in parentheses, not braces.
import (
"database/sql"
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
_ "github.com/lib/pq"
)