Newbie question importing Go github repository in project Visual studio Code

Hi everybody,

I am getting started with Go and would like to test to print table content to the console using a github project. I already have git installed and imported the module using:
git clone https://github.com/jedib0t/go-pretty.git

When I copy the code in the example of the documentation and store it as main.go I have the following code in VSC:

package main

import (
“os”

"github.com/jedib0t/go-pretty/table"

)

func main() {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", “First Name”, “Last Name”, “Salary”})
t.AppendRows([]table.Row{
{1, “Arya”, “Stark”, 3000},
{20, “Jon”, “Snow”, 2000, “You know nothing, Jon Snow!”},
})
t.AppendRow([]interface{}{300, “Tyrion”, “Lannister”, 5000})
t.AppendFooter(table.Row{"", “”, “Total”, 10000})
t.Render()
}

When I try to run this code using the terminal : go run main.go
I get the following error:
cannot find package “github.com/jedib0t/go-pretty/table

I think it must be something small but I am completely stuck.

Any tips you might have would be very much appreciated.

Thanks
Peter

Did you install the package via go get?

1 Like

Thanks for your reply, No I didn’t, sorry. I thought you needed to use the clone command

What would you recommend?

EDIT: I got it to work!! Thanks for taking the time to help a newbie out GreyShatter and apologies for the stupidity!!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.