With all the examples out there and a little experimentation, I found the 
solution I needed. Here's the tree from the 'top' directory:
├── dfs
│   ├── dfs.go
│   ├── dfs_test.go
│   └── go.mod
├── first.go
├── go.mod
└── ModuleDFS
Here are the file contents starting from the top of the directory structure 
on down:

go.mod:
======
module ModuleDFS
require _/dfs v0.0.0
replace _/dfs => ./dfs
go 1.14

first.go:
======
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"

"_/dfs"
)

func main() {
gr := make(map[string][]string)
//       vertex --^    ^-- slice of vertices adjacent to this vertex
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
in := scanner.Text()
// in: A B C etc.
// Ctrl-D at end!
flds := strings.Fields(in) // split line into fields
vs := make([]string, 0)
// set up vertices connected to first vertex at index 0
for f := 1; f < len(flds); f++ {
vs = append(vs, flds[f])
}
gr[flds[0]] = vs
}
if err := scanner.Err(); err != nil {
log.Fatalln("Error scanning:", err)
}
for k, v := range gr {
fmt.Printf("%s:%v\n", k, v)
}
dfs.SetupDfs(gr)
}
// check simply checks for an error w/o inline code everywhere
//  Also, since a fatal error occurred, this is no slowdown!
func check(why string, err error) {
if err != nil {
log.Fatalln(why, ":", err)
}
}

Directory dfs:
==========
go.mod:
======
module _/ModuleDFS/dfs
go 1.14

dfs.go:
=====
package dfs
import "fmt"
// setupDFS initialized dfs variables
func SetupDfs(gr map[string][]string) {
nT := 0 // Total nodes in whole graph
for n := range gr {
nT += len(gr[n])
}
visited := make(map[string]bool, nT)
fmt.Println("Total nodes:", nT, "Visited:", visited)
dfs(gr, "a", visited)
fmt.Println("Final:", visited)
}
// dfs peforms a Depth First Search of all nodes
func dfs(gr map[string][]string, at string,
vs map[string]bool) map[string]bool {
if vs[at] == true {
return vs
}
vs[at] = true
neighbors := gr[at]
fmt.Println("neighbors[", at, "]:", gr[at])
for _, next := range neighbors {
fmt.Println("next:", next)
dfs(gr, next, vs)
}
return vs
}
// Hello -- the most basic of testing
func Hello() string {
return "Hello World"
}

dfs_test.go:
=========
package dfs
import "testing"
func TestDfs(t *testing.T) {
want := "Hello World"
if got := Hello(); got != want {
t.Errorf("Hello() = %q, want %q", got, want)
}
}

Thanks for your help!
On Wednesday, March 11, 2020 at 4:07:18 PM UTC-4, Dean Schulze wrote:
>
> The docs for modules assume that you'll be publishing your golang modules 
> (actually a git push) to the few public repos that golang has built in 
> support for.  I want to use a private repo, but there doesn't seem to be 
> any docs for that.  This post 
> <https://medium.com/cloud-native-the-gathering/go-modules-with-private-git-repositories-dfe795068db4>
>  has 
> some suggestions, but it relies on entries in .gitcofig that will interfere 
> with normal access to those public repos.  It doesn't mention using ssh 
> keys for authentication.  I assume this is what go does for the public 
> reops it has built in support for.
>
> I hope there is a better way.  Is there?
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/28e0825a-56ed-429c-b5a2-aa9ea56dd9c7%40googlegroups.com.

Reply via email to