Issue in importing gen package - go

I am trying to import gen package in main.go file.
import ("golang.org/x/text/internal/gen")
But I am facing following error and still I haven't find solution to this:
main.go:7:2: use of internal package golang.org/x/text/internal/gen not allowed
Could someone help me to solve this problem. Thank you.

Related

Import a specific package inside a GitHub repository

Intention
I intend to import exactly this package (subdirectory) to reuse its methods and types:
https://github.com/hemantasapkota/go-convexhull/tree/master/convexhull
Which is inside this repository:
https://github.com/hemantasapkota/go-convexhull
Tried
I tried to import the whole repository:
import (
"github.com/hemantasapkota/go-convexhull"
)
But go get github.com/hemantasapkota/go-convexhull is throwing errors. Since its main.go file contains import "github.com/hemantasapkota/glu" which is a private repository.
Question
How can I import just the package convexhull inside a sub-directory of that repository? I mean, I don't need its main.go and its troubles.
Of course, I can copy over the files of convexhull sub-directory/package into my project. But I'm looking for a way to just simply import it from GitHub. Any idea?
This worked:
import (
"github.com/hemantasapkota/go-convexhull/convexhull"
)
However, when building, I received this error which I need to figure out:
Build Error: go test -c -o /tmp/__debug_bin930480706 -gcflags all=-N -l .
package printer/app/threed/detect/dental
imports github.com/hemantasapkota/go-convexhull/convexhull
imports github.com/go-gl/gl: build constraints exclude all Go files in /home/m3/go/pkg/mod/github.com/go-gl/gl#v0.0.0-20190320180904-bf2b1f2f34d7 (exit status 1)

Could not import ... (no required module provides package)

I am following this tutorial.
I initialised my project and got the dependencies via
go mod init github.com/martin-helmich/kubernetes-crd-example
go get k8s.io/client-go#v0.17.0
go get k8s.io/apimachinery#v0.17.0
I have a Go file that uses import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1".
VS Code shows me could not import k8s.io/apimachinery/pkg/apis/meta/v1 (no required module provides package "k8s.io/apimachinery/pkg/apis/meta/v1"). What am I doing wrong here? Is my Go installation not correct?

Import from the same package, using package name

I've added dependency to https://github.com/sjwhitworth/golearn in Golang project. I've tried to build application, however I am getting error from one of the classes from golearn - this one: https://github.com/sjwhitworth/golearn/blob/master/base/dataframe_go.go : undefined: base. I've tried to find what is the base package refering to. There is no imported package base in this file so it looks like it is import from the same package but using the package name. I mean, dataframe_go.go is in the same package (base) where is the imported struct (FixedDataGrid). How to solve this import issue?

python lambda not able to import user defined modules

I have a python lambda which turns out to be a bit long so we decided to split it into modules. and now when i try to import the module in the lambda_handler its seems to be giving following error
Unable to import module 'defghi': attempted relative import with no known parent package
abc.py which has got lambda_handler in it, is trying to import the defghi.py methods as follows
from defghi import some_method_1, some_method_2
tried this as well
from .defghi import some_method_1, some_method_2
both the files are in the same directory
any sort of help would be appreciated, Thanks in adavance
Finally got that working it was the build scripts which where causing the issue in my project.
The build script which created the zip file where expecting only one .py file in the directory which was a problem. So the zip created never had other files which then gave error cannot import.
So to answer the question its perfectly fine to split the big lambdas into modules and keep them a bit readable and import into the main lambda_handler the required modules.

How to include external file in Go?

I'm using LiteIDE for Go. I have a Go file located here:
/Users/username/go/src/src/Helper/Helper.go
When I include the file using:
import "../Helper"
I get this error:
can't load package: /Users/username/go/src/src/projectA/main.go:4:8:
local import "../Helper" in non-local package
Any ideas what I'm doing wrong?
You import packages by import path. For package Helper, located in $GOPATH/src/Helper/, use:
import "Helper"
While they can work in some cases, relative paths aren't supported by the go toolchain, and are discouraged.

Resources