go fmt ... (#562)
diff --git a/internal/chunkedfile/chunkedfile.go b/internal/chunkedfile/chunkedfile.go
index 0751e85..c50aa7d 100644
--- a/internal/chunkedfile/chunkedfile.go
+++ b/internal/chunkedfile/chunkedfile.go
@@ -13,10 +13,10 @@
//
// Example:
//
-// x = 1 / 0 ### "division by zero"
-// ---
-// x = 1
-// print(x + "") ### "int + string not supported"
+// x = 1 / 0 ### "division by zero"
+// ---
+// x = 1
+// print(x + "") ### "int + string not supported"
//
// A client test feeds each chunk of text into the program under test,
// then calls chunk.GotError for each error that actually occurred. Any
diff --git a/lib/math/math.go b/lib/math/math.go
index 07eb4a7..6676d07 100644
--- a/lib/math/math.go
+++ b/lib/math/math.go
@@ -17,53 +17,52 @@
// Module math is a Starlark module of math-related functions and constants.
// The module defines the following functions:
//
-// ceil(x) - Returns the ceiling of x, the smallest integer greater than or equal to x.
-// copysign(x, y) - Returns a value with the magnitude of x and the sign of y.
-// fabs(x) - Returns the absolute value of x as float.
-// floor(x) - Returns the floor of x, the largest integer less than or equal to x.
-// mod(x, y) - Returns the floating-point remainder of x/y. The magnitude of the result is less than y and its sign agrees with that of x.
-// pow(x, y) - Returns x**y, the base-x exponential of y.
-// remainder(x, y) - Returns the IEEE 754 floating-point remainder of x/y.
-// round(x) - Returns the nearest integer, rounding half away from zero.
+// ceil(x) - Returns the ceiling of x, the smallest integer greater than or equal to x.
+// copysign(x, y) - Returns a value with the magnitude of x and the sign of y.
+// fabs(x) - Returns the absolute value of x as float.
+// floor(x) - Returns the floor of x, the largest integer less than or equal to x.
+// mod(x, y) - Returns the floating-point remainder of x/y. The magnitude of the result is less than y and its sign agrees with that of x.
+// pow(x, y) - Returns x**y, the base-x exponential of y.
+// remainder(x, y) - Returns the IEEE 754 floating-point remainder of x/y.
+// round(x) - Returns the nearest integer, rounding half away from zero.
//
-// exp(x) - Returns e raised to the power x, where e = 2.718281… is the base of natural logarithms.
-// sqrt(x) - Returns the square root of x.
+// exp(x) - Returns e raised to the power x, where e = 2.718281… is the base of natural logarithms.
+// sqrt(x) - Returns the square root of x.
//
-// acos(x) - Returns the arc cosine of x, in radians.
-// asin(x) - Returns the arc sine of x, in radians.
-// atan(x) - Returns the arc tangent of x, in radians.
-// atan2(y, x) - Returns atan(y / x), in radians.
-// The result is between -pi and pi.
-// The vector in the plane from the origin to point (x, y) makes this angle with the positive X axis.
-// The point of atan2() is that the signs of both inputs are known to it, so it can compute the correct
-// quadrant for the angle.
-// For example, atan(1) and atan2(1, 1) are both pi/4, but atan2(-1, -1) is -3*pi/4.
-// cos(x) - Returns the cosine of x, in radians.
-// hypot(x, y) - Returns the Euclidean norm, sqrt(x*x + y*y). This is the length of the vector from the origin to point (x, y).
-// sin(x) - Returns the sine of x, in radians.
-// tan(x) - Returns the tangent of x, in radians.
+// acos(x) - Returns the arc cosine of x, in radians.
+// asin(x) - Returns the arc sine of x, in radians.
+// atan(x) - Returns the arc tangent of x, in radians.
+// atan2(y, x) - Returns atan(y / x), in radians.
+// The result is between -pi and pi.
+// The vector in the plane from the origin to point (x, y) makes this angle with the positive X axis.
+// The point of atan2() is that the signs of both inputs are known to it, so it can compute the correct
+// quadrant for the angle.
+// For example, atan(1) and atan2(1, 1) are both pi/4, but atan2(-1, -1) is -3*pi/4.
+// cos(x) - Returns the cosine of x, in radians.
+// hypot(x, y) - Returns the Euclidean norm, sqrt(x*x + y*y). This is the length of the vector from the origin to point (x, y).
+// sin(x) - Returns the sine of x, in radians.
+// tan(x) - Returns the tangent of x, in radians.
//
-// degrees(x) - Converts angle x from radians to degrees.
-// radians(x) - Converts angle x from degrees to radians.
+// degrees(x) - Converts angle x from radians to degrees.
+// radians(x) - Converts angle x from degrees to radians.
//
-// acosh(x) - Returns the inverse hyperbolic cosine of x.
-// asinh(x) - Returns the inverse hyperbolic sine of x.
-// atanh(x) - Returns the inverse hyperbolic tangent of x.
-// cosh(x) - Returns the hyperbolic cosine of x.
-// sinh(x) - Returns the hyperbolic sine of x.
-// tanh(x) - Returns the hyperbolic tangent of x.
+// acosh(x) - Returns the inverse hyperbolic cosine of x.
+// asinh(x) - Returns the inverse hyperbolic sine of x.
+// atanh(x) - Returns the inverse hyperbolic tangent of x.
+// cosh(x) - Returns the hyperbolic cosine of x.
+// sinh(x) - Returns the hyperbolic sine of x.
+// tanh(x) - Returns the hyperbolic tangent of x.
//
-// log(x, base) - Returns the logarithm of x in the given base, or natural logarithm by default.
+// log(x, base) - Returns the logarithm of x in the given base, or natural logarithm by default.
//
-// gamma(x) - Returns the Gamma function of x.
+// gamma(x) - Returns the Gamma function of x.
//
// All functions accept both int and float values as arguments.
//
// The module also defines approximations of the following constants:
//
-// e - The base of natural logarithms, approximately 2.71828.
-// pi - The ratio of a circle's circumference to its diameter, approximately 3.14159.
-//
+// e - The base of natural logarithms, approximately 2.71828.
+// pi - The ratio of a circle's circumference to its diameter, approximately 3.14159.
var Module = &starlarkstruct.Module{
Name: "math",
Members: starlark.StringDict{
@@ -146,7 +145,8 @@
})
}
-// log wraps the Log function
+// log wraps the Log function
+//
// as a Starlark built-in that accepts int or float arguments.
func log(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
diff --git a/lib/proto/proto.go b/lib/proto/proto.go
index 36f0023..e8b235d 100644
--- a/lib/proto/proto.go
+++ b/lib/proto/proto.go
@@ -9,21 +9,21 @@
//
// This package defines several types of Starlark value:
//
-// Message -- a protocol message
-// RepeatedField -- a repeated field of a message, like a list
+// Message -- a protocol message
+// RepeatedField -- a repeated field of a message, like a list
//
-// FileDescriptor -- information about a .proto file
-// FieldDescriptor -- information about a message field (or extension field)
-// MessageDescriptor -- information about the type of a message
-// EnumDescriptor -- information about an enumerated type
-// EnumValueDescriptor -- a value of an enumerated type
+// FileDescriptor -- information about a .proto file
+// FieldDescriptor -- information about a message field (or extension field)
+// MessageDescriptor -- information about the type of a message
+// EnumDescriptor -- information about an enumerated type
+// EnumValueDescriptor -- a value of an enumerated type
//
// A Message value is a wrapper around a protocol message instance.
// Starlark programs may access and update Messages using dot notation:
//
-// x = msg.field
-// msg.field = x + 1
-// msg.field += 1
+// x = msg.field
+// msg.field = x + 1
+// msg.field += 1
//
// Assignments to message fields perform dynamic checks on the type and
// range of the value to ensure that the message is at all times valid.
@@ -35,31 +35,30 @@
// performs a dynamic check to ensure that the RepeatedField holds
// only elements of the correct type.
//
-// type(msg.uint32s) # "proto.repeated<uint32>"
-// msg.uint32s[0] = 1
-// msg.uint32s[0] = -1 # error: invalid uint32: -1
+// type(msg.uint32s) # "proto.repeated<uint32>"
+// msg.uint32s[0] = 1
+// msg.uint32s[0] = -1 # error: invalid uint32: -1
//
// Any iterable may be assigned to a repeated field of a message. If
// the iterable is itself a value of type RepeatedField, the message
// field holds a reference to it.
//
-// msg2.uint32s = msg.uint32s # both messages share one RepeatedField
-// msg.uint32s[0] = 123
-// print(msg2.uint32s[0]) # "123"
+// msg2.uint32s = msg.uint32s # both messages share one RepeatedField
+// msg.uint32s[0] = 123
+// print(msg2.uint32s[0]) # "123"
//
// The RepeatedFields' element types must match.
// It is not enough for the values to be merely valid:
//
-// msg.uint32s = [1, 2, 3] # makes a copy
-// msg.uint64s = msg.uint32s # error: repeated field has wrong type
-// msg.uint64s = list(msg.uint32s) # ok; makes a copy
+// msg.uint32s = [1, 2, 3] # makes a copy
+// msg.uint64s = msg.uint32s # error: repeated field has wrong type
+// msg.uint64s = list(msg.uint32s) # ok; makes a copy
//
// For all other iterables, a new RepeatedField is constructed from the
// elements of the iterable.
//
-// msg.uints32s = [1, 2, 3]
-// print(type(msg.uints32s)) # "proto.repeated<uint32>"
-//
+// msg.uints32s = [1, 2, 3]
+// print(type(msg.uints32s)) # "proto.repeated<uint32>"
//
// To construct a Message from encoded binary or text data, call
// Unmarshal or UnmarshalText. These two functions are exposed to
@@ -75,7 +74,6 @@
//
// See proto_test.go for an example of how to use the 'proto'
// module in an application that embeds Starlark.
-//
package proto
// TODO(adonovan): Go and Starlark API improvements:
@@ -111,8 +109,8 @@
// for a Starlark thread to use this package.
//
// For example:
-// SetPool(thread, protoregistry.GlobalFiles)
//
+// SetPool(thread, protoregistry.GlobalFiles)
func SetPool(thread *starlark.Thread, pool DescriptorPool) {
thread.SetLocal(contextKey, pool)
}
@@ -305,10 +303,9 @@
// When a message descriptor is called, it returns a new instance of the
// protocol message it describes.
//
-// Message(msg) -- return a shallow copy of an existing message
-// Message(k=v, ...) -- return a new message with the specified fields
-// Message(dict(...)) -- return a new message with the specified fields
-//
+// Message(msg) -- return a shallow copy of an existing message
+// Message(k=v, ...) -- return a new message with the specified fields
+// Message(dict(...)) -- return a new message with the specified fields
func (d MessageDescriptor) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
dest := &Message{
msg: newMessage(d.Desc),
@@ -1219,11 +1216,10 @@
//
// An EnumValueDescriptor has the following fields:
//
-// index -- int, index of this value within the enum sequence
-// name -- string, name of this enum value
-// number -- int, numeric value of this enum value
-// type -- EnumDescriptor, the enum type to which this value belongs
-//
+// index -- int, index of this value within the enum sequence
+// name -- string, name of this enum value
+// number -- int, numeric value of this enum value
+// type -- EnumDescriptor, the enum type to which this value belongs
type EnumValueDescriptor struct {
Desc protoreflect.EnumValueDescriptor
}
diff --git a/starlarkstruct/struct.go b/starlarkstruct/struct.go
index ea2b1f6..2282d7f 100644
--- a/starlarkstruct/struct.go
+++ b/starlarkstruct/struct.go
@@ -4,7 +4,6 @@
// Package starlarkstruct defines the Starlark types 'struct' and
// 'module', both optional language extensions.
-//
package starlarkstruct // import "go.starlark.net/starlarkstruct"
// It is tempting to introduce a variant of Struct that is a wrapper
@@ -36,10 +35,9 @@
//
// An application can add 'struct' to the Starlark environment like so:
//
-// globals := starlark.StringDict{
-// "struct": starlark.NewBuiltin("struct", starlarkstruct.Make),
-// }
-//
+// globals := starlark.StringDict{
+// "struct": starlark.NewBuiltin("struct", starlarkstruct.Make),
+// }
func Make(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(args) > 0 {
return nil, fmt.Errorf("struct: unexpected positional arguments")