This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"flag" | |
"fmt" | |
"net/http" | |
"sync/atomic" | |
"time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"sync/atomic" | |
"time" | |
) | |
const ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package contador_test | |
import ( | |
"fmt" | |
"sync" | |
"sync/atomic" | |
"testing" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package contador_test | |
import ( | |
"fmt" | |
"sync" | |
"testing" | |
"time" | |
) | |
// TestContadorConcurrenteConWaitGroup incrementa un contador con goroutines y waitgroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package contador_test | |
import ( | |
"fmt" | |
"testing" | |
"time" | |
) | |
// TestContadorConcurrente incrementa un contador con goroutines | |
func TestContadorConcurrente(t *testing.T) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"sync/atomic" | |
"time" | |
"github.com/sony/gobreaker" // obtener la dependencia con: go get github.com/sony/gobreaker | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package racecondition_test | |
import ( | |
"fmt" | |
"sync" | |
"sync/atomic" | |
"testing" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package contador_test | |
import ( | |
"fmt" | |
"testing" | |
"time" | |
) | |
// valores que usaremos en todos los tests | |
const ( |