Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go build command failed #1

Closed
leonardyhuang opened this issue Oct 24, 2023 · 4 comments
Closed

go build command failed #1

leonardyhuang opened this issue Oct 24, 2023 · 4 comments
Assignees

Comments

@leonardyhuang
Copy link

Hi,

Thank you for forking of https://github.com/mthenw/serverless-go-plugin.

Continuing from issue mthenw/serverless-go-plugin#41, I managed to install your package. However, there was this error (see below) when I ran sls deploy. And, I think the command I set on serverless.yml was correct, cmd: 'go build -ldflags="-s -w"'.

Error log:

Error:
Error: error compiling function (cwd: .)
    at Go.execCompilation (file:///Users/leonardy/go/src/anapp/node_modules/serverless-plugin-go/index.js:194:13)
    at async Go.compile (file:///Users/leonardy/go/src/anapp/node_modules/serverless-plugin-go/index.js:146:5)
    at async Promise.all (index 0)
    at async Go.compileFunctions (file:///Users/leonardy/go/src/anapp/node_modules/serverless-plugin-go/index.js:87:5)
    at async PluginManager.runHooks (/opt/homebrew/lib/node_modules/serverless/lib/classes/plugin-manager.js:530:9)
    at async PluginManager.invoke (/opt/homebrew/lib/node_modules/serverless/lib/classes/plugin-manager.js:563:9)
    at async PluginManager.spawn (/opt/homebrew/lib/node_modules/serverless/lib/classes/plugin-manager.js:585:5)
    at async before:deploy:deploy (/opt/homebrew/lib/node_modules/serverless/lib/plugins/deploy.js:48:11)
    at async PluginManager.runHooks (/opt/homebrew/lib/node_modules/serverless/lib/classes/plugin-manager.js:530:9)
    at async PluginManager.invoke (/opt/homebrew/lib/node_modules/serverless/lib/classes/plugin-manager.js:563:9)
    at async PluginManager.run (/opt/homebrew/lib/node_modules/serverless/lib/classes/plugin-manager.js:604:7)
    at async Serverless.run (/opt/homebrew/lib/node_modules/serverless/lib/serverless.js:179:5)
    at async /opt/homebrew/lib/node_modules/serverless/scripts/serverless.js:819:9
GoPlugin: Error compiling function (cwd: .): Command failed: go build -ldflags="-s -w" -o .bin/receive receive/main.go
/bin/sh: go: command not found

Here is the content of my serverless.yml:

service: anapp

frameworkVersion: '3'

provider:
  name: aws
  runtime: provided.al2
  architecture: arm64

  stage: ${opt:stage, 'dev'}
  region: us-east-1
  environment: ${file(.env.${self:provider.stage}.yml)}

package:
  patterns:
    - '!./**'
    - './bin/**'

functions:
  receive:
    handler: receive/main.go
    events:
      - http:
          path: ${self:custom.functionPath.${self:provider.stage}}/receive
          method: post
    timeout: 30
    memorySize: 128
  verify:
    handler: verify/main.go
    events:
      - http:
          path: ${self:custom.functionPath.${self:provider.stage}}/receive
          method: get
    timeout: 30
    memorySize: 128

custom:
  go:
    baseDir: '.'
    binDir: '.bin'
    cmd: 'go build -ldflags="-s -w"'
    monorepo: false
    env:
      GOOS: 'linux'
      CGO_ENABLED: '0'

plugins:
  - serverless-plugin-go

Really appreciate your assistance, thanks.

@danteay danteay self-assigned this Oct 25, 2023
@danteay
Copy link
Contributor

danteay commented Oct 25, 2023

Thanks @leonardyhuang will check today!!

@danteay
Copy link
Contributor

danteay commented Oct 25, 2023

@leonardyhuang The fix is already on master!! check it out 🙌🏼

@danteay
Copy link
Contributor

danteay commented Oct 27, 2023

I'm clossing this issue as the tests works for latest release!!

@danteay danteay closed this as completed Oct 27, 2023
@leonardyhuang
Copy link
Author

Sorry for the delayed response. I will give it a try asap. Thanks for the fix 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants