快速开始

This guide gets you started with Tableau in Go with a simple working example.

Prerequisites

  • Go, any one of the three latest major releases of Go.
  • Protocol buffer compiler, protoc, version 3.
  • Go plugins for the protocol compiler:
    1. Install the protocol compiler plugins for Go using the following commands:

      go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
      
    2. Update your PATH so that the protoc compiler can find the plugins:

      export PATH="$PATH:$(go env GOPATH)/bin"
      

Get the example code

The example code is part of the tableau/demo repo.

  1. Download the repo as a zip file and unzip it, or clone the repo:

    git clone https://github.com/tableauio/demo
    
  2. Change to the quick start example directory:

    cd demo/examples/helloworld
    

Run the example

From the examples/helloworld directory:

  1. Change dir to excel2proto, compile and execute:

    go run main.go
    

    Then proto files will be generated to examples/helloworld/proto.

  2. Change dir to excel2conf, generate *.pb.go and then compile and execute:

    bash gen.sh
    go run main.go
    

    Then *.pb.go files will be generated to examples/helloworld/protoconf, and JSON files will be generated to examples/helloworld/excel2conf/_out.

Congratulations! You’ve just run a modern configuration converter application with Tableau.