Run function from otherScript using GetComponent

Hi everyone
I know this question has been ask quite a lot, yet I’m facing some trouble
I’m making a script of AI in wich there is a moment when the AI have to choose a target in a list of gameobject called listOfSeenTarget.

GameObject ChooseTarget()
        float totalHPoftarget = 200f;
        GameObject targetResult = null;
        foreach(GameObject go in listOfSeenTarget)
            float goHP = 0;
            if(go.GetComponent("TankController") != null)
                goHP = go.GetComponent("TankController").GetTotalHP();
            if(go.GetComponent("AITank") != null)
                goHP = go.GetComponent("AITank").GetTotalHP();

            if (goHP < totalHPoftarget)
                totalHPoftarget = goHP;
                targetResult = go;

        return targetResult;

The return value is the object to focus (which got the less health on all other object).
In the list of GameObject, each of them contain a script :
TankController.cs if the gameobject is the player
AITank if the gameobject is an other AI
Both script contain a method public float GetTotalHP ()
but editor tell me
“‘Component’ does not contain a definition for ‘GetTotalHP’”
Any idea on how to fix this ?

try this:

if(go.GetComponent<TankController>() != null)
    goHP = go.GetComponent<TankController>().GetTotalHP();

if(go.GetComponent<AITank>() != null)
    goHP = go.GetComponent<AITank>().GetTotalHP();