Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6211649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:22:34+00:00 2026-05-24T06:22:34+00:00

I have just put together a Go package that is going to be a

  • 0

I have just put together a Go package that is going to be a part in a fairly large system with a lot of shared packages. I was able to get it to compile by writing its Makefile such that the compiler is called with -I flags:

include $(GOROOT)/src/Make.inc

TARG=foobar
GOFILES=\
    foobar.go\

foobar:
    $(GC) -I$(CURDIR)/../intmath -I$(CURDIR)/../randnum foobar.go

include $(GOROOT)/src/Make.pkg

It compiles just fine, and being a good boy, I wrote a comprehensive set of tests. However, when I try to run the tests with gotest, I get a compile error:

$ gotest
rm -f _test/foobar.a
8g  -o _gotest_.8 foobar.go  foobar_test.go
foobar.go:4: can't find import: intmath
make: *** [_gotest_.8] Error 1
gotest: "C:\\msys\\bin\\sh.exe -c \"gomake\" \"testpackage\" \"GOTESTFILES=foobar_test.go\"" failed: exit status 2

So, the Go file itself will compile when I use the -I flags to tell it where to find the intmath and randnum packages, but gotest doesn’t seem to use the Makefile.

Answering peterSO’s question:
foobar.go’s import section looks like this:

import (
    "intmath"
    "randnum"
    "container/vector"
)

And the compile works fine as long as I have the -I flags going to the compiler. I have tried to use relative paths, like this:

import (
    "../intmath"
    "../randnum"
    "container/vector"
)

but that just doesn’t seem to work.

EDIT: answering further peterSO questions:

GOROOT is set to C:\Go the directory where I have all of the Go stuff — aside from my source code — installed. I was expecting the relative path to be relative to the directory in which the source file lives.

My source tree looks like this:

server/
    foobar/
    randnum/
    intmath/

So, while I am open to a different, more Go-idiomatic directory structure, my instinct is to arrange them as peers.

Is there some way that I can nudge gotest into compiling foobar.go with the needed flags?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:22:34+00:00Added an answer on May 24, 2026 at 6:22 am

    Create the Windows source code directory structure:

    C:\server
    C:\server\foobar
    C:\server\intnum
    

    For intnum.go:

    package intnum
    
    func IntNum() int {
        return 42
    }
    

    Makefile:

    include $(GOROOT)/src/Make.inc
    TARG=server/intnum
    GOFILES=\
        intnum.go\
    include $(GOROOT)/src/Make.pkg
    

    Run:

    $ cd c/server/intnum
    $ make install
    

    For foobar.go:

    package foobar
    
    import (
        "math"
        "server/intnum"
    )
    
    func FooBar() float64 {
        return float64(intnum.IntNum()) * math.Pi
    }
    

    Makefile:

    include $(GOROOT)/src/Make.inc
    TARG=server/foobar
    GOFILES=\
        foobar.go\
    include $(GOROOT)/src/Make.pkg
    

    Run:

    $ cd /c/server/foobar
    $ make install
    

    After the install, the intnum.a and foobar.a package files will be in the $GOROOT\pkg\windows_386\server (C:\Go\pkg\windows_386\server) directory`.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have MANY small Test Projects where I put together just enough code to
I have put together a HTTP driven API using the WCF WebAPI that uses
I have an HttpModule that I have put together from cobbling a couple of
I just put together a small script for a team of users that collects
I have just started learning and have put together the form below. The confusion
I'm a beginner and have just about managed to put together this website with
Greetings: I have put together a RESTful web service in .NET 3.5 that takes
I have a string, for example; llama,goat,cow and I just need to put a
I have just inherited a server application, however it seems that the only copy
I have just joined a on going project based on spring framework. It usage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.