Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

improve godoc; replace Loggers with embeded fields; refactor Ctx api #673

Merged
merged 1 commit into from
Jun 7, 2017
Merged

Conversation

jmank88
Copy link
Collaborator

@jmank88 jmank88 commented May 28, 2017

#672

This PR improves documentation, and refactors the API around Ctx, primarily by dissolving the Loggers struct and embedding the fields directly.

context.go Outdated
GOPATH := getEnv(env, "GOPATH")
if GOPATH == "" {
GOPATH = defaultGOPATH()
func (c *Ctx) SetGOPATH(gopath string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other things being equal, I think I'd rather keep this as a constructor. The shape of the existing API more clearly suggests that the GOPATH should really only be set at initialization time, and not modified later.

Is there a functional reason for this change that I'm missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed like it was left in an unusual form as an artifact of old behavior, with the GOPATH logic being the only real work left. In particular, having parameters to pass values straight through to exported fields on the returned struct seems like odd boilerplate - and it was going to compound without Loggers.

Would a better name (Init), or better documentation make usage more clear? Alternatively, the GOPATH portion I've isolated could be encapsulated in a helper function (goodFnName(gopath, wd string) (gopath, gopaths string, err error)), so that NewContext can just set fields.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, ok - given that my objection is about a suggestion to the user, I think that as long as the documentation clearly cautions the user appropriately, then it's OK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added another iteration with more documentation.

// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package dep is a prototype dependency management library.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, yeah, we need to improve all of these

@sdboyer
Copy link
Member

sdboyer commented Jun 2, 2017

rebase?

@sdboyer
Copy link
Member

sdboyer commented Jun 6, 2017

sorry, needs another rebase :/

@jmank88 jmank88 closed this Jun 7, 2017
@jmank88 jmank88 reopened this Jun 7, 2017
Copy link
Member

@sdboyer sdboyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thank you!

@sdboyer sdboyer merged commit f4027ef into golang:master Jun 7, 2017
@jmank88 jmank88 deleted the godoc branch June 7, 2017 23:37
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants