Skip to content

Commit b913b5e

Browse files
authored
bump: go 1.19 and fix: fmt issues (#519)
1 parent 14aa194 commit b913b5e

File tree

13 files changed

+40
-35
lines changed

13 files changed

+40
-35
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run:
2-
go: 1.18
2+
go: 1.19
33
linters:
44
disable:
55
- gosimple

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/TheAlgorithms/Go
22

3-
go 1.18
3+
go 1.19

graph/articulationpoints.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func ArticulationPoint(graph *Graph) []bool {
5050
// articulationPointHelper is a recursive function to traverse the graph
5151
// and mark articulation points. Based on the depth first search transversal
5252
// of the graph, however modified to keep track and update the
53-
// `child_cnt`, `discovery_time`` and `earliest_discovery` slices defined above
53+
// `child_cnt`, `discovery_time` and `earliest_discovery` slices defined above
5454
func articulationPointHelper(
5555
apHelperInstance *apHelper,
5656
vertex int,

graph/floydwarshall_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77

88
const float64EqualityThreshold = 1e-9
99

10-
//almostEqual subtracts two float64 variables and returns true if they differ less then float64EqualityThreshold
11-
//reference: https://stackoverflow.com/a/47969546
10+
// almostEqual subtracts two float64 variables and returns true if they differ less then float64EqualityThreshold
11+
// reference: https://stackoverflow.com/a/47969546
1212
func almostEqual(a, b float64) bool {
1313
return math.Abs(a-b) <= float64EqualityThreshold
1414
}
1515

16-
//IsAlmostEqualTo verifies if two WeightedGraphs can be considered almost equal
16+
// IsAlmostEqualTo verifies if two WeightedGraphs can be considered almost equal
1717
func (a *WeightedGraph) IsAlmostEqualTo(b WeightedGraph) bool {
1818
if len(*a) != len(b) {
1919
return false

math/binary/checkisnumberpoweroftwo.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ package binary
1111
// like 10...0 in binary, and numbers one less than the power of 2
1212
// are represented like 11...1.
1313
// Therefore, using the and function:
14-
// 10...0
15-
// & 01...1
16-
// 00...0 -> 0
14+
//
15+
// 10...0
16+
// & 01...1
17+
// 00...0 -> 0
18+
//
1719
// This is also true for 0, which is not a power of 2, for which we
1820
// have to add and extra condition.
1921
func IsPowerOfTwo(x int) bool {

math/pythagoras/pythagoras.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import (
44
"math"
55
)
66

7-
//Vector defines a tuple with 3 values in 3d-space
7+
// Vector defines a tuple with 3 values in 3d-space
88
type Vector struct {
99
x float64
1010
y float64
1111
z float64
1212
}
1313

14-
//Distance calculates the distance between to vectors with the Pythagoras theorem
14+
// Distance calculates the distance between to vectors with the Pythagoras theorem
1515
func Distance(a, b Vector) float64 {
1616
res := math.Pow(b.x-a.x, 2.0) + math.Pow(b.y-a.y, 2.0) + math.Pow(b.z-a.z, 2.0)
1717
return math.Sqrt(res)

math/pythagoras/pythagoras_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var distanceTest = []struct {
1818
{"random short vectors", Vector{1, 1, 1}, Vector{2, 2, 2}, 1.73},
1919
}
2020

21-
//TestDistance tests the Function Distance with 2 vectors
21+
// TestDistance tests the Function Distance with 2 vectors
2222
func TestDistance(t *testing.T) {
2323
t.Parallel() // marks TestDistance as capable of running in parallel with other tests
2424
for _, tt := range distanceTest {

other/nested/nestedbrackets.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ package nested
88
//
99
// A sequence of brackets `s` is considered properly nested
1010
// if any of the following conditions are true:
11-
// - `s` is empty;
12-
// - `s` has the form (U) or [U] or {U} where U is a properly nested string;
13-
// - `s` has the form VW where V and W are properly nested strings.
11+
// - `s` is empty;
12+
// - `s` has the form (U) or [U] or {U} where U is a properly nested string;
13+
// - `s` has the form VW where V and W are properly nested strings.
1414
//
1515
// For example, the string "()()[()]" is properly nested but "[(()]" is not.
1616
//

search/binary.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ func BinaryIterative(array []int, target int) (int, error) {
3737
return -1, ErrNotFound
3838
}
3939

40-
//Returns index to the first element in the range [0, len(array)-1] that is not less than (i.e. greater or equal to) target.
41-
//return -1 and ErrNotFound if no such element is found.
40+
// Returns index to the first element in the range [0, len(array)-1] that is not less than (i.e. greater or equal to) target.
41+
// return -1 and ErrNotFound if no such element is found.
4242
func LowerBound(array []int, target int) (int, error) {
4343
startIndex := 0
4444
endIndex := len(array) - 1
@@ -59,8 +59,8 @@ func LowerBound(array []int, target int) (int, error) {
5959
return startIndex, nil
6060
}
6161

62-
//Returns index to the first element in the range [lowIndex, len(array)-1] that is greater than target.
63-
//return -1 and ErrNotFound if no such element is found.
62+
// Returns index to the first element in the range [lowIndex, len(array)-1] that is greater than target.
63+
// return -1 and ErrNotFound if no such element is found.
6464
func UpperBound(array []int, target int) (int, error) {
6565
startIndex := 0
6666
endIndex := len(array) - 1

search/interpolation.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ package search
44
// if the entity is present, it will return the index of the entity, if not -1 will be returned.
55
// see: https://en.wikipedia.org/wiki/Interpolation_search
66
// Complexity
7-
// Worst: O(N)
8-
// Average: O(log(log(N)) if the elements are uniformly distributed
9-
// Best: O(1)
7+
//
8+
// Worst: O(N)
9+
// Average: O(log(log(N)) if the elements are uniformly distributed
10+
// Best: O(1)
11+
//
1012
// Example
11-
// fmt.Println(InterpolationSearch([]int{1, 2, 9, 20, 31, 45, 63, 70, 100},100))
13+
//
14+
// fmt.Println(InterpolationSearch([]int{1, 2, 9, 20, 31, 45, 63, 70, 100},100))
1215
func Interpolation(sortedData []int, guess int) (int, error) {
1316
if len(sortedData) == 0 {
1417
return -1, ErrNotFound

0 commit comments

Comments
 (0)