Write a Golang program that utilizes TensorFlow to train a neural network on the MNIST dataset for handwritten digit recognition, and evaluates its performance on a test set.
PLAINFORMAT
package main

import (
	"fmt"
	"log"

	tf "github.com/tensorflow/tensorflow/tensorflow/go"
	"github.com/tensorflow/tensorflow/tensorflow/go/op"
)

const (
	imageSize   = 28 * 28
	numLabels   = 10
	hiddenLayer = 1024
	batchSize   = 100
	numSteps    = 1000
)

func main() {
	root := op.NewScope()
	X := op.Placeholder(root.SubScope("input"), tf.Float, op.PlaceholderShape(tf.MakeShape(batchSize, imageSize)))
	Y := op.Placeholder(root.SubScope("output"), tf.Float, op.PlaceholderShape(tf.MakeShape(batchSize, numLabels)))

	w1 := weightVariable(root, []int64{imageSize, hiddenLayer})
	b1 := biasVariable(root, []int64{hiddenLayer})

	w2 := weightVariable(root, []int64{hiddenLayer, numLabels})
	b2 := biasVariable(root, []int64{numLabels})

	layer1 := op.Add(root, op.MatMul(root, X, w1), b1)
	layer1 = op.ReLU(root, layer1)

	logits := op.Add(root, op.MatMul(root, layer1, w2), b2)

	predictions := op.ArgMax(root, logits, 1)
	labels := op.ArgMax(root, Y, 1)
	correctPrediction := op.Equal(root, predictions, labels)
	accuracy := op.ReduceMean(root, op.Cast(root, correctPrediction, tf.Float))

	loss := op.ReduceMean(root, op.SoftmaxCrossEntropyWithLogits(root, logits, Y))
	trainStep := op.GradientDescent(root, loss, 0.5)

	graph, err := root.Finalize()
	if err != nil {
		log.Fatal(err)
	}

	sess, err := tf.NewSession(graph, &tf.SessionOptions{})
	if err != nil {
		log.Fatal(err)
	}
	defer sess.Close()

	mnist := loadMNISTData()

	for i := 0; i < numSteps; i++ {
		batchX, batchY := mnist.train.nextBatch(batchSize)
		if _, err = sess.Run(map[tf.Output]*tf.Tensor{X: batchX, Y: batchY}, []tf.Output{trainStep}, nil); err != nil {
			log.Fatal(err)
		}

		if i%100 == 0 {
			testAccuracy, err := sess.Run(map[tf.Output]*tf.Tensor{X: mnist.test.images, Y: mnist.test.labels}, []tf.Output{accuracy}, nil)
			if err != nil {
				log.Fatal(err)
			}
			fmt.Printf("Step %d, test accuracy: %f\n", i, testAccuracy[0].Value())
		}
	}
}

func weightVariable(s *op.Scope, shape []int64) tf.Output {
	init := op.TruncatedNormal(s.SubScope("weight"), shape, tf.Float)
	return op.Variable(s, init.Shape(), tf.Float)
}

func biasVariable(s *op.Scope, shape []int64) tf.Output {
	init := op.Zeros(s.SubScope("bias"), shape, tf.Float)
	return op.Variable(s, init.Shape(), tf.Float)
}

func loadMNISTData() *mnistData {
	// Load the MNIST dataset using a library or custom code.
	// The data should be preprocessed and split into training and testing sets.
	// Return an instance of mnistData with train and test attributes containing images and labels.
}

type mnistData struct {
	train *mnistDataSet
	test  *mnistDataSet
}

type mnistDataSet struct {
	images *tf.Tensor
	labels *tf.Tensor
}