Vim-go: Question: Is GoRun supposed to work with cgo or not?

Created on 18 May 2018  路  5Comments  路  Source: fatih/vim-go

Specs:

Vim 8.0.1766
vim-go: the latest (GoUpdateBinaries)
System: GNU / Debian testing 64-bit
Go version: 1.10.1

When I run :GoRun %, I see only

Greetings from Go!
Goodbye from Go!

When i run the code with go run cGoDemo.go inside my terminal, I can see

Greetings from Go!
Calling C Code!
Goodbye from Go!

Is this the expected behavior?

Here's the code:

package main

// #include <stdio.h>
// void helloC() {
//     printf("Calling C code!\n");
// }
import "C"

import "fmt"

func main() {
    fmt.Println("Greetings from Go!")
    C.helloC()
    fmt.Println("Goodbye from Go!!")
}
bug

All 5 comments

What you're seeing is not expected behavior. I can duplicate what you're seeing.

Is everything alright with :GoRun %? I have the following code and does not work with the aforementioned command:

package main

import (
    "fmt"
    "os"
    "path/filepath"
    "time"
)

func main() {

    var myDate string
    if len(os.Args) != 2 {
        fmt.Printf("filename: %s\n", filepath.Base(os.Args[0]))
        return
    }

    myDate = os.Args[1]
    date, err := time.Parse("02 January 2006", myDate)
    if err == nil {
        fmt.Println("Full date:", date)
        fmt.Println("Time:", date.Day(), date.Month(), date.Year())
    } else {
        fmt.Println(err)
    }
}

As soon as I run it with :GoRun % "20 July 2008", I get filename: main.

When I run it with go run command I get the proper output:

$ go run various/dateFormatting/main.go "20 July 2008"
Full date: 2008-07-20 00:00:00 +0000 UTC
Time: 20 July 2008

@stefanos82 if you believe there is an additional problem with :GoRun, please open a separate issue so that concerns about multiple issues don't get conflated.

With respect to your most recent question here, I suspect you're running into an edge case with how :GoRun handles arguments; it deserves its own issue, though.

OK, I will copy the content from above and open a new ticket.

Thanks @bhcleek

There have been some changes to :GoRun recently, and I can no longer duplicate this. I'm not sure if vim-go's changes account for this or whether it's something about more recent versions of Go.

In any case, I'm closing this since it seems to be solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Michael-F-Ellis picture Michael-F-Ellis  路  3Comments

jongillham picture jongillham  路  3Comments

danielmanesku picture danielmanesku  路  4Comments

SirmaXX picture SirmaXX  路  3Comments

cassiobotaro picture cassiobotaro  路  3Comments