Help me debug this code

I've been staring at this going mad:

private var state : int = 1;
var speed : int = 6;
var direction : int = 1;
var rotateSpeed : int = 5;

function Update () {
transform.Translate(Vector3.forward * speed * Time.deltaTime);
if (EasyBotCheck.okay == false)
    {
    //change direction
    direction = Random.Range(2,3);
    if (direction == 2)
        {
        GoLeft();
        }
    if (direction ==3)
        {
        GoRight();
        }
    }

function GoLeft() {
transform.Rotate(Vector3.up, -90 * rotateSpeed * Time.smoothDeltaTime);
direction = 1;
}

function GoRight () {
transform.Rotate(Vector3.up, 90 * rotateSpeed * Time.smoothDeltaTime);
direction = 1;
}

}

And, in case you're wondering, it's supposed to be an AI script and I haven't even had a chance to test it because of:

Assets/Game Name/Prefab/Players/Bots/EasyBotMovement.js(22,10): BCE0044: expecting (, found 'GoLeft'.

You cannot define functions within other functions. The brace to close your update must precede your other function definitions.