You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: udp.go
    path of file: ./repos/cloudprober/servers/udp
    
    the code of the file until where you have to start completion: // Copyright 2017-2020 The Cloudprober Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*
Package udp implements a UDP server.  It listens on a
given port and echos whatever it receives.  This is used for the UDP probe.
*/
package udp

import (
	"context"
	"errors"
	"fmt"
	"net"
	"runtime"
	"strings"

	"github.com/google/cloudprober/logger"
	"github.com/google/cloudprober/metrics"
	configpb "github.com/google/cl
    
func (s *Server) Start(ctx context.Context, dataChan chan<- *metrics.EventMetrics) error {
	var ms []ipv6.Message              // Used for batch read-write
	buf := make([]byte, maxPacketSize) // Used for single packet read-write (windows)

	if s.advancedReadWrite {
		ms = make([]ipv6.Message, batchSize)
		for i := 0; i < batchSize; i++ {
			ms[i].Buffers = [][]byte{make([]byte, maxPacketSize)}
			ms[i].OOB = ipv6.NewControlMessage(ipv6.FlagDst)
		}
	}

	// Setup a background function to close connection if context is canceled.
	// Typically, this is not what we want (close something started outside of
	// Start function), but in case of UDP we don't have better control than
	// this. One thing we can consider is to re-setup connection in Start().
	go func() {
		<-ctx.Done()
		s.conn.Close()
	}()

	switch s.c.GetType() {

	case configpb.ServerConf_ECHO:
		s.l.Infof("Starting UDP ECHO server on port %d", int(s.c.GetPort()))

		var rwerr *readWriteErr
		for {
			if s.advancedReadWrite {
				rwerr = s.readAndEchoBatch(ms)
			} else {
				rwerr = s.readAndEchoSimple(buf)
			}
			if rwerr != nil {
				if errors.Is(rwerr.err, net.ErrClosed) {
					s.l.Warning("connection closed, stopping the start goroutine")
					return nil
				}
				s.l.Error(rwerr.Error())
			}
		}

	case configpb.ServerConf_DISCARD:
		s.l.Infof("Starting UDP DISCARD server on port %d", int(s.c.GetPort()))

		var err error
		for {
			if s.advancedReadWrite {
				_, err = s.p6.ReadBatch(ms, 0)
			} else {
				_, _, err = s.conn.ReadFromUDP(buf)
			}

			if err != nil {
				if errors.Is(err, net.ErrClosed) {
					return nil
				}
				s.l.Errorf("ReadFromUDP: %v", err)
			}
		}
	}

	return nil
}