31

I'm trying to build and run a repo (https://github.com/hyperledger/fabric/tree/master) but this error keeps popping up and still I haven't found a solution to this.

consensus.go:12:2: use of internal package github.com/hyperledger/fabric/internal/pkg/identity not allowed

This is just one of many files that give this error. I'm pretty sure I'm doing something wrong since this repo is suppose to be working.

Go version :

go version go1.13.5 linux/amd64

OS : Linux Mint 19.2 Cinnamon

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Tuan
  • 635
  • 1
  • 8
  • 15

2 Answers2

66

Internal packages (packages that are inside a folder that has an internal folder in their path) can only be imported from packages rooted at the parent of the internal folder.

E.g. a package pkg/foo/internal/bar can be imported by the package pkg/foo/internal/baz and also from pkg/foo/baz, but cannot be imported by the package pkg nor can it be imported by pkg/bar. This is by design. This is so big, complex packages can be broken into smaller packages without having to expose internals.

You have to treat internal packages as "private" or non-existent from the "outside".

See related: Can I develop a go package in multiple source directories?

Read more about internal packages at Command go: Internal Directories.

Internal packages are a compiler restriction. If you want to expose them (if you want to use an internal package) in your own project, you have to remove the internal folder, and then of course you have to change the imports (import paths) too.

icza
  • 389,944
  • 63
  • 907
  • 827
  • Thank you for the quick reply. Since it won't be the case to move the files I want to build, from the way I understand is that I should change the GOPATH src folder such that the library becomes allowed. I hope I'm right @icza. – Tuan Dec 15 '19 at 10:46
  • 1
    @Tuan Internal packages are a compiler restriction. If you want to expose them, you have to remove the `internal` folder, and then of course you have to change the imports (import paths) too. – icza Dec 15 '19 at 11:08
-3

Change fyne.io/fyne/v2/internal/widget To fyne.io/fyne/v2/widget

Just remove the /internal from the package path inside the code editor

  • 2
    This question has already been answered and is fairly old. You should only post an additional answer if it adds something to the conversation (e.g. a new technology that changes the answer). – John Glenn Jan 28 '22 at 05:51