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: ping_test.go
    path of file: ./repos/agones/test/e2e
    
    the code of the file until where you have to start completion: // Copyright 2018 Google LLC All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (t
    
func externalPort(svc *corev1.Service, port corev1.ServicePort) (int32, error) {
	switch svc.Spec.Type {
	case corev1.ServiceTypeNodePort:
		return port.NodePort, nil

	case corev1.ServiceTypeLoadBalancer:
		return port.Port, nil
	}

	return 0, errors.New("could not find external port")
}