Activate/deactivate all GameObjects with same tag c#

I’m trying to create a script which would automatically activate and reactivate all GameObjects with the tag ‘Flare’ on them. ‘flareOnTime’ is for how long it is active and ‘flareOffTime’ is for how long it is inactive. I’m stuck right now and cannot figure out what is wrong with my code. I would reaaly appriciate any help.

Code:

using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour {


	public float flareOnTime;
	public float flareOffTime;

	GameObject[] gos;



	// Use this for initialization
	void Start () {

		GameObject[] gos = GameObject.FindGameObjectsWithTag("Flare");

	

		StartCoroutine("BlinkFlare");


	}
	
	// Update is called once per frame
	void Update () {
	
	}

	IEnumerator BlinkFlare() {

		while (true) {
			yield return new WaitForSeconds (flareOnTime);
			foreach (GameObject go in gos){
			go.SetActive(false);
			}
			yield return new WaitForSeconds (flareOffTime);
			foreach (GameObject go in gos){
			go.SetActive(true);
			}
		}
	}

}

The error is that you’re re-initalizing the array of GameObjects by doing this:

GameObject[] gos = GameObject.FindGameObjectsWithTag("Flare");

instead of this:

gos = GameObject.FindGameObjectsWithTag("Flare");

Essentially, when you write "MyClass foo = ", you’re introducing a new variable named “foo” in the local scope, hiding any variable named foo in outer scopes - like class variables. So, in your start method, you’re making a new array, and filling it with all of the objects tagged with “Flare”, but you’re not doing anything with it. The BlinkFlare method uses the empty game object field variable, and thus does nothing.