Code Monkey home page Code Monkey logo

Comments (3)

acidjazz avatar acidjazz commented on May 30, 2024

So.. I'm still new to Go.. but doesn't the import of the other source files take care of this? how does specifying multiple files in the build help debug? Do you get better error reporting?

from fume-cli.

umbellate avatar umbellate commented on May 30, 2024

This is not related to error reporting nor debugging. This is simply desiring a similar behavior to go build foo.go main.go akin to in C doing cc -o myexec foo.c main.c. I do not want to import another module (because of the steps involved in syncing go.mod and the various branches inducing an extra step), but rather just have the code all in one package, just multiple files.

That being said, I could just do import "mymodule" and include a replace mymodule => ./mymodulelocal line in go.mod of the user of mymodule. Just figured it would be nice to ape how things actually can work with go build and allow multiple files.

I'll go ahead and close as my main gripe has been synching go.mod and doing the replace workaround is fine for me.

from fume-cli.

umbellate avatar umbellate commented on May 30, 2024

This is closed, but an untested possible solution to what I'd like would be:

diff --git a/src/lib/deploytasks.ts b/src/lib/deploytasks.ts
index 74aec6d..5e5437b 100644
--- a/src/lib/deploytasks.ts
+++ b/src/lib/deploytasks.ts
@@ -267,10 +267,23 @@ exports.handler = async (event, context) => {
     await execa(this.packager, args)
   }
 
+  async goFindSourceFiles(task: ListrTaskWrapper<any, any>) {
+    var sources = [];
+    fs.readdirSync('.').forEach(file => {
+      if (file.endsWith('.go')) {
+        sources.push(file);
+      }
+    });
+    return sources
+  }
+
   async goCompile(task: ListrTaskWrapper<any, any>) {
     task.title = 'Compiling go binary'
     await this.deployment.update('GO_COMPILE')
-    await execa('go', ['build', '-o', 'main', 'main.go'], { env: { GOOS: 'linux', GOARCH: 'amd64' } })
+    var sources = await goFindSourceFiles(task) 
+    var build = ['build', '-o', 'main']
+    var fullBuild = build.concat(sources)
+    await execa('go', fullBuild, { env: { GOOS: 'linux', GOARCH: 'amd64' } })
   }
 
   async goArchive(task: ListrTaskWrapper<any, any>) {

from fume-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.