Git Product home page Git Product logo

Comments (6)

mschoch avatar mschoch commented on May 26, 2024

The functions do not need to be exported because they are used by the same package (main) where they are defined. The application builds fine:

$ git clone [email protected]:blevesearch/beer-search.git
Cloning into 'beer-search'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 7463 (delta 1), reused 3 (delta 1), pack-reused 7459
Receiving objects: 100% (7463/7463), 2.12 MiB | 25.28 MiB/s, done.
Resolving deltas: 100% (2902/2902), done.
$ cd beer-search 
$ ls
data  go.mod  go.sum  http_util.go  main.go  main_test.go  mapping_example1.go  mapping_example2.go  mapping.go  README.md  static
$ go build
$ ./beer-search 
2020/10/05 11:47:25 GOMAXPROCS: 32
2020/10/05 11:47:25 Creating new index...
2020/10/05 11:47:25 Listening on :8094
2020/10/05 11:47:25 Indexing...
2020/10/05 11:47:26 Indexed 1000 documents, in 1.08s (average 1.08ms/doc)
^C

It appears maybe you are attempting to simply run the main.go, but that is not supported:

$ go run main.go
# command-line-arguments
./main.go:57:24: undefined: buildIndexMapping
./main.go:89:12: undefined: staticFileRouter
./main.go:99:29: undefined: docIDLookup

from beer-search.

mcolburn avatar mcolburn commented on May 26, 2024

Thank you for your prompt reply!

go build

does work fine.

Might I suggest then, that you update the README to indicate that this example is meant to be built and then run from the executable?

from beer-search.

mschoch avatar mschoch commented on May 26, 2024

Can you help me understand why you expected go run main.go to work? In my experience that never works for real applications, as they typically grow beyond a single file, and typing go run file1.go file2.go file3.go etc becomes unwieldy.

from beer-search.

mcolburn avatar mcolburn commented on May 26, 2024

from beer-search.

mschoch avatar mschoch commented on May 26, 2024

That would not be accurate either, it does work using go run, you just have to use it correctly:

$ go run main.go http_util.go mapping.go
2020/10/05 12:14:56 GOMAXPROCS: 32
2020/10/05 12:14:56 Opening existing index...
2020/10/05 12:14:56 Listening on :8094
^Csignal: interrupt

When using go run you have supply all the required file names.

from beer-search.

mcolburn avatar mcolburn commented on May 26, 2024

from beer-search.

Related Issues (10)

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.