1

I'm building golang lambda functions using the serverless framework in AWS CodeBuild. This project is in a private bitbucket repository. And the CodeBuild source is the bitbucket repo

I'm having some problems of using local packages in the code.

I have this project structure

hello
   test
      test.go
   main.go
serverless.yml
...other files

what I'm trying to do is to use package test in hello/test/test.go in the hello/main.go.

And I've tried 2 options.

  1. Import the package using "myproject/hello/test"
  2. Using bitbucket url and dep ensure. Moving test to another project.

the problems:

  1. in AWS CodeBuild, the package cannot be found as the real package directory is /....aws path/bitbucket.org/<username>/<repo>/ and the $GOPATH is /...aws path/.
  2. dep ensure freezes when writing the private bitbucket repo. I'm assuming that it's because authentication issues?

So, what can I do to use my golang packages in AWS CodeBuild? And it's a private repo not a public one.

6
  • The import name for the package is "bitbucket.org/<username>/<repo>/test", not "myproject/hello/test". (Maybe there's a hello in there somewhere too. Hard to tell since the names in your question are inconsistent) Commented Apr 4, 2018 at 7:56
  • Hi @Peter, yeah.. that should be it in the CodeBuild instance, but in my developer environment, it's only a folder and not starting with "bitbucket.org...". Or should I use that format in my dev environment? Commented Apr 4, 2018 at 7:58
  • 1
    Yes, you should: golang.org/doc/code.html Commented Apr 4, 2018 at 8:04
  • right! Ok then! If you make it as answer I'll make it as the answer! Thanks! Commented Apr 4, 2018 at 8:46
  • This question has got to be a duplicate, but apparently my search mojo left me and I can't find a good existing question. Commented Apr 4, 2018 at 9:15

1 Answer 1

1

Based on Peter's comments, I resolved the issue by using the full path of my bitbucket repo in my $GOPATH/src.

so the path should be bitbucket.org/<username>/<repo>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.