From 6b3cf463650093c51e4540144b8b776ff338477e Mon Sep 17 00:00:00 2001 From: Greg Bowyer Date: Mon, 10 Jul 2017 22:03:31 -0700 Subject: [PATCH] [README] Fix tabulation in `README.MD` --- README.md | 102 +++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 27a6a57..681d491 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ Here's an example program that consumes compiled [PlanOut](http://github.com/fac package main import ( - "encoding/json" - "fmt" - "io/ioutil" - "github.com/biased-unit/planout-golang" + "encoding/json" + "fmt" + "io/ioutil" + "github.com/biased-unit/planout-golang" ) // Example input structure @@ -36,48 +36,48 @@ type ExampleStruct struct { } func main() { - // Read PlanOut code from file on disk. - data, _ := ioutil.ReadFile("test/simple_ops.json") - - // The PlanOut code is expected to use json. - // This format is the same as the output of - // the PlanOut compiler webapp - // http://facebook.github.io/planout/demo/planout-compiler.html - var js map[string]interface{} - json.Unmarshal(data, &js) - - // Set the necessary input parameters required to run - // the experiments. For instance, simple_ops.json expects - // the value for 'userid' to be set. + // Read PlanOut code from file on disk. + data, _ := ioutil.ReadFile("test/simple_ops.json") + + // The PlanOut code is expected to use json. + // This format is the same as the output of + // the PlanOut compiler webapp + // http://facebook.github.io/planout/demo/planout-compiler.html + var js map[string]interface{} + json.Unmarshal(data, &js) + + // Set the necessary input parameters required to run + // the experiments. For instance, simple_ops.json expects + // the value for 'userid' to be set. example := ExampleStruct{Member: 101, String: "test-string"} - params := make(map[string]interface{}) - params["experiment_salt"] = "expt" - params["userid"] = generateString() + params := make(map[string]interface{}) + params["experiment_salt"] = "expt" + params["userid"] = generateString() params["struct"] = example - // Construct an instance of the Interpreter object. - // Initialize Salt and set Inputs to params. - expt := &planout.Interpreter{ - Salt: "global_salt", - Evaluated: false, - Inputs: params, - Outputs: map[string]interface{}{}, - Overrides: map[string]interface{}{}, + // Construct an instance of the Interpreter object. + // Initialize Salt and set Inputs to params. + expt := &planout.Interpreter{ + Salt: "global_salt", + Evaluated: false, + Inputs: params, + Outputs: map[string]interface{}{}, + Overrides: map[string]interface{}{}, Code: js, - } - - // Call the Run() method on the Interpreter instance. - // The output of the run will contain the dictionary - // of variables and associated values that were evaluated - // as part of the experiment. - output, ok := expt.Run() - if !ok { - fmt.Println("Failed to run the experiment") - } else { - fmt.Printf("Params: %v\n", params) - } - - fmt.Println(output) + } + + // Call the Run() method on the Interpreter instance. + // The output of the run will contain the dictionary + // of variables and associated values that were evaluated + // as part of the experiment. + output, ok := expt.Run() + if !ok { + fmt.Println("Failed to run the experiment") + } else { + fmt.Printf("Params: %v\n", params) + } + + fmt.Println(output) } ``` @@ -130,17 +130,17 @@ This example consumes multiple compiled [PlanOut](http://github.com/facebook/pla package main func main() { - js1 := readTest("test/simple_ops.json") - js2 := readTest("test/random_ops.json") - js3 := readTest("test/simple.json") + js1 := readTest("test/simple_ops.json") + js2 := readTest("test/random_ops.json") + js3 := readTest("test/simple.json") - inputs := make(map[string]interface{}) - inputs["userid"] = "test-id" + inputs := make(map[string]interface{}) + inputs["userid"] = "test-id" - n := planout.NewSimpleNamespace("simple_namespace", 100, "userid", inputs) - n.AddExperiment("simple ops", js1, 10) - n.AddExperiment("random ops", js2, 10) - n.AddExperiment("simple", js3, 80) + n := planout.NewSimpleNamespace("simple_namespace", 100, "userid", inputs) + n.AddExperiment("simple ops", js1, 10) + n.AddExperiment("random ops", js2, 10) + n.AddExperiment("simple", js3, 80) out, ok = := n.Run() }