This week, I ran the Go and C++ versions side by side on the same test data and opened my first pull request, so my supervisor, Dr. Shawn, can see real proof that Go behaves like C++. I also ported bulk orders, where one order carries a spreadsheet of many participants.

Running Both Versions Side by Side

With last week’s practice setup, I ran five cases on both versions, each with its own copy of the test database. The cases were a paid order becoming an entry, the email and order note, the change form, bad records, and the exports. In the first three, both versions made the same entries, emails and notes. The only differences were details that change on every run, like the signing time of the JWT, the signed code inside each QR code.

The other two cases showed differences. When a record had a list where text was expected, the C++ version stopped, and an order that came in before it restarted was never processed. The Go version logged the error and went on to the next order. Both versions made the same export file, byte for byte, but the C++ command-line tool crs_export stopped at its first entry, while Go’s -export option wrote every row.

Opening My First Pull Request

Next, I opened my first pull request, so Dr. Shawn can review the first four pieces of work together. For each case, the description shows the Go result next to the C++ one, with screenshots. I also added a note for the switch-over. The test settings still hold the C++ export template, and Go prints it as plain text instead of data. So each competition’s templates must change to Go templates when the system moves to Go.

Porting Bulk Orders

A bulk order is split into one child order for each row of its spreadsheet. I ported it in three parts, and all three are now committed. sheetOrders turns one page of the sheet into child orders. readSheet reads CSV, XLSX and ODS files with orcus, the same open-source programs C++ uses. makeOrderMany creates the child orders in WooCommerce. When a new order’s sheet has a mistake, it writes the error on the order, tells the buyer and puts the order on hold.

While reading the code before committing, I found one problem. Orcus writes each page as JSON, and Go’s usual way of reading JSON turns every number into a type that cellText, which turns each cell into text, does not handle. Ages and phone numbers would have disappeared without any error. Go’s UseNumber option fixed it, and a new test proves that an age cell now comes through. My lesson is that reading every line before committing is worth the time.

Next Week’s Plan

Bulk orders took the whole week, so two jobs are still left. First, I will test bulk orders on the test shop with orders I buy myself, so every email to the buyer comes to me. Then I will open its pull request and port the last two jobs: setting up a new competition’s database, and compaction, which shrinks the database after records are deleted.

Categories: Experiential

0 Comments

Leave a Reply

Avatar placeholder

This site uses Akismet to reduce spam. Learn how your comment data is processed.