duanchao1002 2018-05-02 13:48
浏览 42


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.


package main

import {
    _ "github.com/lib/pq"

type App struct {
    Router *mux.Router
    DB *sql.DB
//init and other functions here


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.

  • 写回答

1条回答 默认 最新

  • dougong5285 2018-05-02 13:50

    The import block is supposed to be surrounded in parentheses, not braces.

    import (
        _ "github.com/lib/pq"
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 微信公众号如何开发网页
  • ¥15 h3.6m 人类行为预测论文复现
  • ¥50 wordpress项目注册报失败刷新后其实是成功状态,请求排查原因
  • ¥20 linxu服务器僵尸进程不释放,代码如何修改?
  • ¥15 pycharm激活不成功
  • ¥40 如果update 一个列名为参数的value
  • ¥15 基于51单片机的水位检测系统设计中LCD1602一直不显示
  • ¥15 OCS2安装出现问题,请大家给点意见
  • ¥15 ros小车启动launch文件报错
  • ¥15 vs2015到期想登陆但是登陆不上