0

I plan on building a very simple webapp on Go using it's html/template module for the front end.

One typical function for the app is as follows:

  • Get some data from external app
  • Display that data in a table in one of the Go templates
  • Permit the user to edit certain rows, sort etc.
  • Retrieve data from the table to be stored in DB in backend, or sent on to other application.

Very early version of the template looks like this:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=9">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Delivery App</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
    crossorigin="anonymous">
</head>

<body>
  <div class="container">
    <table class="table">
      <thead>
        <tr>
          <th scope="col">Id</th>
          <th scope="col">Tran id</th>
          <th scope="col">Assembly Instructions</th>
          <th scope="col">Miscalleanous</th>
        </tr>
      </thead>
      <tbody>
        {{ range . }}
        <tr>
          <th scope="row">{{.Id}}</th>
          <td>{{.TranId}}</td>
          <td>{{.Memo}}</td>
          <td>{{.AssemblyInstructions}}</td>
          <td>{{.AssemblingUnits}}</td>
        </tr>
        {{ end }}
      </tbody>
    </table>

  </div>
  <!-- /container -->
</body>

</html>

I would like to parse data from the table element and store to db, or process further in subsequent request to another service. Can anyone recommend some ways this could be achieved?

  • Hi, welcome to SO. This question is way too broad. What have you tried, please show some example code, with input data, point to what's not working, etc. – favoretti Jan 05 '20 at 21:56
  • _"Can this be done..?"_ It certainly can be. _"Or should it be done some other way?"_ that depends on a lot of things. This question is too broad. – icza Jan 05 '20 at 22:01

0 Answers0