cimgui-go: go vendor does not work

I feel like I’m missing a piece of the puzzle 🧩 to getting started with this…

Edit: In case you don’t want to read this whole thread:

It’s a go vendor issue (which they won’t fix). go vendor won’t vendor any directories unless they contain a go file (which C/C++ libraries obviously won’t) and there’s no way to request that it do so.

–

I’m trying to use it like any other go package.

go get "github.com/AllenDang/cimgui-go"
go mod vendor

I import:

import (
	"github.com/AllenDang/cimgui-go"
)

It shows up properly in my go.mod:

require github.com/AllenDang/cimgui-go v0.0.0-20221118092040-698de0565142

But when I go build my application:

% go build
# github.com/AllenDang/cimgui-go
In file included from vendor/github.com/AllenDang/cimgui-go/backend.go:20:
In file included from ./backend.h:3:
./cimgui_wrapper.h:3:10: fatal error: 'cimgui/cimgui.h' file not found
#include "cimgui/cimgui.h"
         ^~~~~~~~~~~~~~~~~
1 error generated.

If I clone this repo separately and go build it seems to build fine.

I’m guessing it has to do with the way vendored modules work? Any idea how to fix it?

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

git submodules aren’t the problem - we want those!

It’s go vendor. It won’t vendor any directories unless they contain a go file - which C/C++ libraries won’t.

Does this mean that we won’t be able to merge https://github.com/AllenDang/cimgui-go/pull/18?

not really - this problem doesn’t depend on cimgui/cimplot being submodules or not; it is caused by lack of go files in cimgui/cimplot dirs

Yes, I looked through all of this and another option is to try to use dummy files, but you would need to put one in every single directory that needs to be copied. I saw an example of this somewhere and it’s messy & error prone.

yah and it will not work, because git will complain about these files

well, so we may try write a design-doc and fill a proposal in go’s repo or do a workaround a create a Makefile like @asmaloney suggested

Yes, I looked through all of this and another option is to try to use dummy files, but you would need to put one in every single directory that needs to be copied. I saw an example of this somewhere and it’s messy & error prone.

Since this project doesn’t control the external ones, you would also need to run an extra command anyways to make it happen, so I figured if we have proper submodules people can do what they like - e.g. I would use Makefiles some other people might write a shellscript.

It’s a total mess & I don’t get why the golang people don’t want to help solve it, but 🤷

could you confirm, that it works with vendoring-mode off

If I:

  • delete vendor/
  • run go get "github.com/AllenDang/cimgui-go"
  • DO NOT run go mod vendor
  • run go build

It builds properly.