You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 8, 2018. It is now read-only.
actual will be assigned bytes.Buffer as the name, which contains the package qualifier as expected.
However, the TypeReference for generated specs (such as a StructSpec or InterfaceSpec) will not have a package qualifier because we don't know the package it belongs to until it is added to a FileSpec:
strSpec:=NewStructSpec("Foo")
// strSpec.GetName() would return "Foo"file:=NewFileSpec("mypackage").CodeBlock(strSpec)
Consider the use case of getting a TypeReference to strSpec from another package. In this example, Foo belongs to package mypackage, and it is used in a function myFunc in package main:
strSpec:=NewStructSpec("Foo")
mypackageFile:=NewFileSpec("mypackage").CodeBlock(strSpec)
// we pass in strSpec as a TypeReference to use it as a result parameterfunc:=NewFuncSpec("myFunc").ResultParameter("", strSpec)
mainFile:=NewFileSpec("main").CodeBlock(func)
Currently, the TypeReference for strSpec would only include its unqualified name, 'Foo'. I propose adding a method to a FileSpec that wraps a TypeReference with the File's package name:
Consider the following code:
actual
will be assignedbytes.Buffer
as the name, which contains the package qualifier as expected.However, the TypeReference for generated specs (such as a StructSpec or InterfaceSpec) will not have a package qualifier because we don't know the package it belongs to until it is added to a FileSpec:
Consider the use case of getting a TypeReference to strSpec from another package. In this example,
Foo
belongs to packagemypackage
, and it is used in a functionmyFunc
in packagemain
:Currently, the TypeReference for strSpec would only include its unqualified name, 'Foo'. I propose adding a method to a FileSpec that wraps a TypeReference with the File's package name:
When
wrappedStrSpec.GetName()
is called, it returnsmypackage.Foo
.Any suggestions / alternative approaches for using generated TypeReferences in other packages?
@kdeenanauth Would love to hear your thoughts on this!
The text was updated successfully, but these errors were encountered: