Skip to content

Commit

Permalink
docs(readme): add build instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
abiriadev committed Dec 12, 2023
1 parent 359187b commit 5a5a6d5
Showing 1 changed file with 140 additions and 0 deletions.
140 changes: 140 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,146 @@ Parameters = "(" [ Type { "," Type } ] ")" .
Query = [ "func" ] [ identifier ] Parameters [ Type ] .
```

## Build Manually

```sh
$ git clone https://github.com/abiriadev/goggle && cd goggle
```

### Build indexer from source and index custom packages

```sh
$ go run ./cmd/indexer
# or
$ go run ./cmd/indexer <space separated list of packages to index>
```

See help page for more information:

```sh
Usage of indexer:
-f string
index format (default "gob")
-o string
path to save index file
```

### Build and run REPL

```sh
$ go run ./cmd/repl
# or optionally pass a path to index file to use
$ go run ./cmd/repl <index file to use>
```

It will then show you a prompt starting with `λ`.

Type any query(like `() bool`) and enter to see the results.

```go
λ () bool
func utf8.FullRune() bool // FullRune reports whether the bytes in p begin with a full UTF-8 encoding of a rune.
func nettest.TestableAddress() bool // TestableAddress reports whether address of network is testable on the current platform configuration.
func nettest.SupportsRawSocket() bool // SupportsRawSocket reports whether the current session is available to use raw sockets.
func nettest.SupportsIPv6() bool // SupportsIPv6 reports whether the platform supports IPv6 networking functionality.
func nettest.SupportsIPv4() bool // SupportsIPv4 reports whether the platform supports IPv4 networking functionality.
func signal.Ignored() bool // Ignored reports whether sig is currently ignored.
func slices.Equal() bool // Equal reports whether two slices are equal: the same length and all elements equal.
func testenv.OptimizationOff() bool // OptimizationOff reports whether optimization is disabled.
func testenv.HasSymlink() bool // HasSymlink reports whether the current system can use os.Symlink.
func testenv.HasSrc() bool // HasSrc reports whether the entire source tree is available under GOROOT.
```

### Build and run Goggle server

```sh
$ go run ./cmd/goggle
```

The default port number is `6099`(L33T or `Gogg`). You can pass `-port` option to change it.

```sh
Usage of goggle:
-port int
port number to bind (default 6099)
```

Try requesting from terminal:

```sh
$ http :6099/search q='() bool' -v

POST /search HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 15
Content-Type: application/json
Host: localhost:6099
User-Agent: HTTPie/3.2.1

{
"q": "() bool"
}

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Length: 1970
Content-Type: text/plain; charset=utf-8
Date: Tue, 12 Dec 2023 04:12:01 GMT

{
"items": [
{
"sim": 0,
"sig": "func utf8.FullRune() bool",
"summary": "FullRune reports whether the bytes in p begin with a full UTF-8 encoding of a rune.",
"link": "https://pkg.go.dev/unicode/utf8#FullRune"
},
{
"sim": 0,
"sig": "func nettest.TestableAddress() bool",
"summary": "TestableAddress reports whether address of network is testable on the current platform configuration.",
"link": "https://pkg.go.dev/golang.org/x/net/nettest#TestableAddress"
},
...
]
}
```

### Build and run frontend

Ensure that you have [Go](https://go.dev), [Task](https://github.com/go-task/task), [Node.js](https://nodejs.org), and [Binaryen](https://github.com/WebAssembly/binaryen) installed.

Then, execuate the following commands:

```sh
$ task wasm-exec syntaxck
$ corepack enable
$ pnpm install --frozen-lockfile
$ cd frontend
```

If you don't want to have local Goggle proxy, you can specify your already-deployed endpoint by setting `VITE_EXTERN_ENDPOINT` variable.

```sh
$ echo 'VITE_EXTERN_ENDPOINT=<type your endpoint url here>' > .env.production
```

Then, run!

```sh
$ pnpm dev
# Or, to use an external endpoint:
$ pnpm dev --mode production
```

For building the frontend for deployment or serving:

```sh
$ pnpm build
```

## :memo: TODO

- [ ] Index
Expand Down

0 comments on commit 5a5a6d5

Please sign in to comment.