Skip to content

Commit

Permalink
Go and Bazel both working ... remove Gazelle for now because it does …
Browse files Browse the repository at this point in the history
…weird stuff with the paths - manually editing the build files makes both go cmdline tool and bazel work with the import paths I want ... will revisit, see bazel-contrib/rules_go#870
  • Loading branch information
skyl committed Jun 11, 2018
1 parent 38abff5 commit 3a24fff
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 21 deletions.
9 changes: 0 additions & 9 deletions BUILD

This file was deleted.

8 changes: 8 additions & 0 deletions src/pango/lib/mathutil/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["multiples.go"],
importpath = "pango/lib/mathutil",
visibility = ["//visibility:public"],
)
13 changes: 13 additions & 0 deletions src/pango/lib/mathutil/multiples.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package mathutil

import "fmt"

// PrintMultiplesOf prints the multiples of a given integer between
// low and high
func PrintMultiplesOf(of int, low int, high int) {
for i := low; i <= high; i++ {
if i%of == 0 {
fmt.Println(i)
}
}
}
9 changes: 1 addition & 8 deletions src/pango/lib/stringutil/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "stringutil",
srcs = ["reverse.go"],
importpath = "lib/stringutil",
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["reverse_test.go"],
Expand All @@ -16,6 +9,6 @@ go_test(
go_library(
name = "go_default_library",
srcs = ["reverse.go"],
importpath = "pango/src/pango/lib/stringutil",
importpath = "pango/lib/stringutil",
visibility = ["//visibility:public"],
)
4 changes: 3 additions & 1 deletion src/pango/lib/stringutil/reverse_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package stringutil

import "testing"
import (
"testing"
)

func TestReverse(t *testing.T) {
cases := []struct {
Expand Down
8 changes: 6 additions & 2 deletions src/pango/services/hello/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go_default_library",
srcs = ["hello.go"],
importpath = "pango/src/pango/services/hello",
importpath = "pango/services/hello",
visibility = ["//visibility:private"],
deps = ["//src/pango/lib/stringutil"],
deps = [
# deps are bazel paths not go import paths ...
"//src/pango/lib/mathutil:go_default_library",
"//src/pango/lib/stringutil:go_default_library",
],
)

go_binary(
Expand Down
4 changes: 3 additions & 1 deletion src/pango/services/hello/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package main

import (
"fmt"
"lib/stringutil"
"pango/lib/stringutil"
"pango/lib/mathutil"
)

func main() {
mathutil.PrintMultiplesOf(5, 10, 100)
fmt.Printf(stringutil.Reverse("\n???Hello, world.!!!"))
}

0 comments on commit 3a24fff

Please sign in to comment.