gopherjs / gopherjs/gopherjs

Serializing a struct and its methods for later reuse

Open
#828 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Go
Stars
13.2k
Forks
573
PR merge metrics
No merged PRs in 30d

Description

Here's the backstory.

Let's say you have a static web site and you want to provide a search via a pre-populated search index. So you write a little program to read in the content of your site and create some search indices. We can use Bleve and utilize its in-memory store since it doesn't rely on os-specific functionality like mmap.

package main

import "github.com/blevesearch/bleve"

func createIndex(idx bleve.Index) {
	//Some code for walking the website and populating the index...
}

func main() {
	index, _ := bleve.NewMemOnly(bleve.NewIndexMapping())
	createIndex(index)
	// The Bleve store is now populated with your sites search indices...
	// ... now what?
}

Given the above pseudocode, being ran with GopherJS, to create the search indices, is there a way to serialize it to a file so it can be pulled in by the website? The above link shows ways to use GopherJS to build an index using GopherJS, but I can't figure out how to use GopherJS to generate a pre-built search index.

Any help will be appreciated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the linked Bleve backstory and the NewMemOnly example first. Investigate whether a populated in-memory Bleve index created through GopherJS can be serialized to a file and loaded by the website; done means establishing a supported approach or clearly documenting that none exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
compilers, search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.