[go-nuts] Re: Homoiconic metaprogramming in Go

2018-12-17 Thread Jason E. Aten
The Go compiler is written in Go, and is open source.  You can do almost 
anything you
want with it (it has a BSD style license), as long as you take the job 
fully yourself.

If you want to interpose a Lisp, I've written a lexically scoped Lisp for 
Go (https://github.com/glycerine/zygomys) and if you need dependent types 
or a
fancy Turing complete type system there is a Go port of Mark Tarver's Shen 
Lisp https://github.com/tiancaiamao/shen-go which
gives you a built in prolog and type solver.  See 
https://shen-language.github.io/ and http://shenlanguage.org/ for a general 
intro.

On Thursday, December 13, 2018 at 11:25:30 PM UTC-6, Dmitry Ponyatov wrote:
>
> Is it possible to do metaprogramming in Go?
>
> What I want to have is a way to run arbitrary code in compile time, which 
> has full access to compiler data structures
> (parsed syntax trees, compiler stages callbacks, direct code generator 
> calls).
>
> As a variant, it can be some Lisp system runs between parser stage and the 
> rest of  Go compiler. 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] symbol lookup error: /root/llvm-install/lib64/libgo.so.8svn: undefined symbol: __get_cpuid_count after "make install"

2018-12-17 Thread Benedikt T
yeah, debug info is still in there...
llvm-ar: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), 
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 
3.2.0, BuildID[sha1]=c2ad3e2441ef2e4afd449627cc6a22d4b256f450, with 
debug_info, not stripped

Is this supposed to happen?

On Tuesday, December 18, 2018 at 12:55:13 AM UTC+1, Benedikt T wrote:
>
> Hi!
>
> it's kind of odd. Using gcc for compilation leads to this error during 
> compilation:
> tools/lto/CMakeFiles/LTO.dir/build.make:278: recipe for target 
> 'lib/libLTO.so.8svn' failed
> make[2]: *** [lib/libLTO.so.8svn] Error 1
> make[2]: *** Deleting file 'lib/libLTO.so.8svn'
> CMakeFiles/Makefile2:20689: recipe for target 
> 'tools/lto/CMakeFiles/LTO.dir/all' failed
> make[1]: *** [tools/lto/CMakeFiles/LTO.dir/all] Error 2
> Makefile:149: recipe for target 'all' failed
> make: *** [all] Error 2
>
> This seems to be related to this: 
> https://groups.google.com/forum/#!topic/llvm-dev/KH3DHQo0A38
>
> Does setting those flags disable the -DCMAKE_BUILD_TYPE=Release 
> -DLLVM_USE_LINKER=gold flags? It seems the built files are quite large... 
> (hinting at additional debug info)
>
> On Monday, December 17, 2018 at 4:20:07 PM UTC+1, Than McIntosh wrote:
>>
>>
>> Thanks for reporting this problem.
>>
>> As Ian said, one of the go library sources includes  , and then 
>> expects to see an inline definition of that routine.
>>
>> I poked around a little and it looks as though versions of clang prior to 
>> 5.0 do provide a definition of , but they don't 
>> define __get_cpuid_count -- that seems to have been added later in this 
>> commit 
>> 
>> .
>>
>> Do you have a later version of clang that you could use as your build 
>> compiler (5.0 later)? Or could you use GCC instead? Either of these should 
>> take care of this problem. In you cmake invocation you'll want to use
>>
>> cmake ...
>>   -DCMAKE_ASM_COMPILER=/usr/bin/gcc \
>>   -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
>>   -DCMAKE_C_COMPILER=/usr/bin/gcc \
>>
>> Or equivalent.
>>
>> I will add a note to the FAQ on this, since others may also run into it.
>>
>> Thanks, Than
>>
>>
>>
>>
>>
>>
>>
>> On Sun, Dec 16, 2018 at 7:17 PM Ian Lance Taylor  
>> wrote:
>>
>>> [ + thanm ]
>>>
>>> On Sat, Dec 15, 2018 at 6:56 AM  wrote:
>>> >
>>> > I'm trying to use the current gollvm build, but it seems there is a 
>>> symbol error. Probably that symbol is absent in the libgo release?
>>> > Anyone had a similar problem or an idea how I can fix that?
>>>
>>> The libgo sources expect __get_cpuid_count to be defined by the
>>> compiler intrinsics header .  This is true for GCC.  The
>>> reference to the symbol is in libgo/go/internal/cpu/cpu_gccgo.c.
>>>
>>> Than: does the LLVM version of  define __get_cpuid_count?  If
>>> not, I guess we need to tweak cpu_gccgo.c.
>>>
>>> Ian
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] symbol lookup error: /root/llvm-install/lib64/libgo.so.8svn: undefined symbol: __get_cpuid_count after "make install"

2018-12-17 Thread Benedikt T
Hi!

it's kind of odd. Using gcc for compilation leads to this error during 
compilation:
tools/lto/CMakeFiles/LTO.dir/build.make:278: recipe for target 
'lib/libLTO.so.8svn' failed
make[2]: *** [lib/libLTO.so.8svn] Error 1
make[2]: *** Deleting file 'lib/libLTO.so.8svn'
CMakeFiles/Makefile2:20689: recipe for target 
'tools/lto/CMakeFiles/LTO.dir/all' failed
make[1]: *** [tools/lto/CMakeFiles/LTO.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

This seems to be related to 
this: https://groups.google.com/forum/#!topic/llvm-dev/KH3DHQo0A38

Does setting those flags disable the -DCMAKE_BUILD_TYPE=Release 
-DLLVM_USE_LINKER=gold flags? It seems the built files are quite large... 
(hinting at additional debug info)

On Monday, December 17, 2018 at 4:20:07 PM UTC+1, Than McIntosh wrote:
>
>
> Thanks for reporting this problem.
>
> As Ian said, one of the go library sources includes  , and then 
> expects to see an inline definition of that routine.
>
> I poked around a little and it looks as though versions of clang prior to 
> 5.0 do provide a definition of , but they don't 
> define __get_cpuid_count -- that seems to have been added later in this 
> commit 
> 
> .
>
> Do you have a later version of clang that you could use as your build 
> compiler (5.0 later)? Or could you use GCC instead? Either of these should 
> take care of this problem. In you cmake invocation you'll want to use
>
> cmake ...
>   -DCMAKE_ASM_COMPILER=/usr/bin/gcc \
>   -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
>   -DCMAKE_C_COMPILER=/usr/bin/gcc \
>
> Or equivalent.
>
> I will add a note to the FAQ on this, since others may also run into it.
>
> Thanks, Than
>
>
>
>
>
>
>
> On Sun, Dec 16, 2018 at 7:17 PM Ian Lance Taylor  > wrote:
>
>> [ + thanm ]
>>
>> On Sat, Dec 15, 2018 at 6:56 AM > wrote:
>> >
>> > I'm trying to use the current gollvm build, but it seems there is a 
>> symbol error. Probably that symbol is absent in the libgo release?
>> > Anyone had a similar problem or an idea how I can fix that?
>>
>> The libgo sources expect __get_cpuid_count to be defined by the
>> compiler intrinsics header .  This is true for GCC.  The
>> reference to the symbol is in libgo/go/internal/cpu/cpu_gccgo.c.
>>
>> Than: does the LLVM version of  define __get_cpuid_count?  If
>> not, I guess we need to tweak cpu_gccgo.c.
>>
>> Ian
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Declaration of interfaces

2018-12-17 Thread Victor Giordano
ahh so, there is nothing more to talk about, thanks for pointing that out.
Maybe in another time discuss if the concept interface of typescript is
kind of barrier-breaker as it includes fields as possible member
declarations, but in another time and place :D




El lun., 17 dic. 2018 a las 20:12, Ian Lance Taylor ()
escribió:

> On Mon, Dec 17, 2018 at 3:08 PM Victor Giordano 
> wrote:
> >
> > This is not legal statement right?
> >
> >
> > var a interface{id int} // let's call it "anonymous interface"
> >
> >
> > if we employ 'interface{}'  to refer to empty interfaces it may has
> sense to think the above declaration as an "anonymous interface" (or inline
> declared interface). I don't know if it would be for better or worse, but
> some that comes from javascript may like it :D, of course someone coming
> from java may be no so much. Don't know here the appreciation.
>
> That statement is not valid, just as
>
> type X interface{id int}
>
> is not valid: because id is not a method.  On the other hand anonymous
> interfaces are supported, and it is valid to write
>
> var a interface { id() int }
>
> Ian
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Declaration of interfaces

2018-12-17 Thread Ian Lance Taylor
On Mon, Dec 17, 2018 at 3:08 PM Victor Giordano  wrote:
>
> This is not legal statement right?
>
>
> var a interface{id int} // let's call it "anonymous interface"
>
>
> if we employ 'interface{}'  to refer to empty interfaces it may has sense to 
> think the above declaration as an "anonymous interface" (or inline declared 
> interface). I don't know if it would be for better or worse, but some that 
> comes from javascript may like it :D, of course someone coming from java may 
> be no so much. Don't know here the appreciation.

That statement is not valid, just as

type X interface{id int}

is not valid: because id is not a method.  On the other hand anonymous
interfaces are supported, and it is valid to write

var a interface { id() int }

Ian

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: bin packing or knapsack

2018-12-17 Thread Vasiliy Tolstov
Thanks, Jason!
вс, 16 дек. 2018 г. в 06:00, Jason E. Aten :
>
> search for branch-and-bound; e.g. 
> https://www.geeksforgeeks.org/0-1-knapsack-using-branch-and-bound/
>
> On Saturday, December 15, 2018 at 5:01:51 PM UTC-6, Vasiliy Tolstov wrote:
>>
>> Hi! i have task  that have some resource constrains for example:
>> Cpu Count
>> Memory size
>> Disk Size
>>
>> And have some servers, so i need optimal put this tasks on this
>> servers (tightly)
>> What is optimal algo for this case? As i see i need 3 dimensions, but
>> i can't rotate items. Where i can read more info about solving bin
>> packing/knapsack for such cases?
>> Thanks!
>>
>> --
>> Vasiliy Tolstov,
>> e-mail: v.to...@selfip.ru
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.



-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Is it possible to go test files priority

2018-12-17 Thread Justin Israel
On Tue, Dec 18, 2018, 8:01 AM  wrote:

> Hi all, Is it possible to set priority to go test files. As per my
> observation go tool runs test cases in alphabetical order of file name. Now
> I want to run files with custom priority. Is it possible?
>

I don't have a direct answer but I feel if it were possible at all it would
involve a custom TestMain:
https://golang.org/pkg/testing/#hdr-Main
Although it doesn't look like enough is exposed to allow you to define the
test order.

Out of curiosity, why is it important to control the order of tests? The
question implies that the tests are interdependant, which seems
undesirable.

> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Is it possible to go test files priority

2018-12-17 Thread durgasomeswararao532
Hi all, Is it possible to set priority to go test files. As per my 
observation go tool runs test cases in alphabetical order of file name. Now 
I want to run files with custom priority. Is it possible?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Go 1.11.4 and Go 1.10.7 are released

2018-12-17 Thread mark
I think we're just waiting on this PR to get 
merged: https://github.com/docker-library/official-images/pull/5197

And then the official docker images should start building automatically.

On Monday, December 17, 2018 at 1:27:01 PM UTC-5, Elliott Polk wrote:
>
> Will there be a Docker image update for go1.11.4? I know that .4 was a 
> quick patch, just wanted to make sure the Docker image is on the deployment 
> path as well.
>
> On Friday, December 14, 2018 at 8:49:20 PM UTC-5, Filippo Valsorda wrote:
>>
>> Hello gophers, 
>>
>> We have just released Go versions 1.11.4 and 1.10.7, minor point 
>> releases. 
>>
>> These releases include fixes to cgo, the compiler, linker, runtime, 
>> documentation, go command, and the net/http and go/types packages. 
>> They include a fix to a bug introduced in Go 1.11.3 and Go 1.10.6 
>> that broke "go get" for import path patterns containing "...". 
>>
>> View the release notes for more information: 
>> https://golang.org/doc/devel/release.html#go1.11.minor 
>>
>> You can download binary and source distributions from the Go web site: 
>> https://golang.org/dl/ 
>>
>> To compile from source using a Git clone, update to the release with 
>> "git checkout go1.11.4" and build as usual. 
>>
>> Thanks to everyone who contributed to the release. 
>>
>> Alla prossima, 
>> Filippo for the Go team 
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Go 1.11.4 and Go 1.10.7 are released

2018-12-17 Thread Elliott Polk
Will there be a Docker image update for go1.11.4? I know that .4 was a 
quick patch, just wanted to make sure the Docker image is on the deployment 
path as well.

On Friday, December 14, 2018 at 8:49:20 PM UTC-5, Filippo Valsorda wrote:
>
> Hello gophers, 
>
> We have just released Go versions 1.11.4 and 1.10.7, minor point releases. 
>
> These releases include fixes to cgo, the compiler, linker, runtime, 
> documentation, go command, and the net/http and go/types packages. 
> They include a fix to a bug introduced in Go 1.11.3 and Go 1.10.6 
> that broke "go get" for import path patterns containing "...". 
>
> View the release notes for more information: 
> https://golang.org/doc/devel/release.html#go1.11.minor 
>
> You can download binary and source distributions from the Go web site: 
> https://golang.org/dl/ 
>
> To compile from source using a Git clone, update to the release with 
> "git checkout go1.11.4" and build as usual. 
>
> Thanks to everyone who contributed to the release. 
>
> Alla prossima, 
> Filippo for the Go team 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] oauth2 for openAPI

2018-12-17 Thread afriyie . abraham
Hi, am new to go language and need help or ideas as how i can write a 
server oauth2 to have a client authenticated..
If there is an already code or if i have to write my own then please help 
with the guidlines of how write it
The client have to send a POST request and get authenticated and then the 
server respond with the 200 success.

The format of the API oauth2 in json is attached bellow.



{
"openapi": "3.0.0",
"info": {
"version": "1.PreR15.1.0",
"title": "NRF OAuth2",
"description": "MYSERVER OAuth2 Authorization"
},
"paths": {
"/oauth2/token": {
"post": {
"summary": "Access Token Request",
"operationId": "AccessTokenRequest",
"tags": [
"Access Token Request"
],
"security": [
{
"basic": []
}
],
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "#/components/schemas/AccessTokenReq"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Access Token Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AccessTokenRsp"
}
}
},
"headers": {
"Cache-Control": {
"$ref": "#/components/headers/cache-control"
},
"Pragma": {
"$ref": "#/components/headers/pragma"
}
}
},
"400": {
"description": "Error in the Access Token Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AccessTokenErr"
}
}
},
"headers": {
"Cache-Control": {
"$ref": "#/components/headers/cache-control"
},
"Pragma": {
"$ref": "#/components/headers/pragma"
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"basic": {
"type": "http",
"scheme": "basic"
}
},
"headers": {
"cache-control": {
"required": true,
"schema": {
"type": "string",
"enum": [
"no-store"
]
}
},
"pragma": {
"required": true,
"schema": {
"type": "string",
"enum": [
"no-cache"
]
}
}
},
"schemas": {
"AccessTokenReq": {
"format": "x-www-form-urlencoded",
"required": [
"grant_type",
"nfInstanceId",
"nfType",
"targetNfType",
"scope"
],
"properties": {
"grant_type": {
"type": "string",
"enum": [
"client_credentials"
]
},
"nfInstanceId": {
"$ref": "TS29571_CommonData.yaml#/components/schemas/NfInstanceId"
},
"nfType": {
"$ref": "TS29510_Nnrf_NFManagement.yaml#/components/schemas/NFType"
},
"targetNfType": {
"$ref": "TS29510_Nnrf_NFManagement.yaml#/components/schemas/NFType"
},
"scope": null,
"type": "string\npattern: '^([a-zA-Z0-9_]*[*]{0,1})$'"
}
},
"AccessTokenRsp": {
"type": "object",
"required": [
"access_token",
"token_type"
],
"properties": {
"access_token": {
"type": "string",
"description": "JWS Compact Serialized representation of JWS signed JSON 
object (AccessTokenClaims)"
},
"token_type": {
"type": "string"
},
"expires_in": {
"type": "integer"
},
"scope": {
"type": "string",
"pattern": "^([a-zA-Z0-9_]*[*]{0,1})$"
}
}
},
"AccessTokenClaims": {
"type": "object",
"required": [
"issuer",
"subject",
"audience",
"scope",
"expiration"
],
"properties": {
"issuer": {
"$ref": "TS29571_CommonData.yaml#/components/schemas/NfInstanceId"
},
"subject": {
"type": "string"
},
"audience": {
"type": "array",
"items": {
"$ref": "TS29571_CommonData.yaml#/components/schemas/NfInstanceId"
}
},
"scope": {
"type": "string",
"pattern": "^([a-zA-Z0-9_]*[*]{0,1})$"
},
"expiration": {
"type": "integer"
}
}
},
"AccessTokenErr": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string",
"enum": [
"invalid_request",
"invalid_client",
"invalid_grant",
"unauthorized_client",
"unsupported_grant_type",
"invalid_sope"
]
},
"error_description": {
"type": "string"
},
"error_uri": {
"type": "string"
}
}
}
}
},
"externalDocs": {
"description": "Documentation",
"url": "http://www.3gpp.org/ftp/Specs/archive/29_series/29.510/;
}
}


BR
Abraham

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-17 Thread howardcshaw
I was not responding to it being or not being metaprogramming, just the 
implication that go generate commands were provided some sort of special 
access. They do not have any access to parsed syntax trees - they can 
themselves parse source files and thus create syntax trees. On re-reading, 
I can see how your description still fits, I was reading an implication 
into it that is not actually stated in the text. Mea culpa.

Howard

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] symbol lookup error: /root/llvm-install/lib64/libgo.so.8svn: undefined symbol: __get_cpuid_count after "make install"

2018-12-17 Thread 'Than McIntosh' via golang-nuts
Thanks for reporting this problem.

As Ian said, one of the go library sources includes  , and then
expects to see an inline definition of that routine.

I poked around a little and it looks as though versions of clang prior to
5.0 do provide a definition of , but they don't
define __get_cpuid_count -- that seems to have been added later in this
commit

.

Do you have a later version of clang that you could use as your build
compiler (5.0 later)? Or could you use GCC instead? Either of these should
take care of this problem. In you cmake invocation you'll want to use

cmake ...
  -DCMAKE_ASM_COMPILER=/usr/bin/gcc \
  -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
  -DCMAKE_C_COMPILER=/usr/bin/gcc \

Or equivalent.

I will add a note to the FAQ on this, since others may also run into it.

Thanks, Than







On Sun, Dec 16, 2018 at 7:17 PM Ian Lance Taylor  wrote:

> [ + thanm ]
>
> On Sat, Dec 15, 2018 at 6:56 AM  wrote:
> >
> > I'm trying to use the current gollvm build, but it seems there is a
> symbol error. Probably that symbol is absent in the libgo release?
> > Anyone had a similar problem or an idea how I can fix that?
>
> The libgo sources expect __get_cpuid_count to be defined by the
> compiler intrinsics header .  This is true for GCC.  The
> reference to the symbol is in libgo/go/internal/cpu/cpu_gccgo.c.
>
> Than: does the LLVM version of  define __get_cpuid_count?  If
> not, I guess we need to tweak cpu_gccgo.c.
>
> Ian
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] [ANN] go-vfs: testing of code that uses os and ioutil made easy

2018-12-17 Thread twpayne
Link: github.com/twpayne/go-vfs

Package vfs provides an abstraction of the os and ioutil packages that is 
easy to test.

Key features:
- File system abstraction layer for commonly-used os and ioutil functions 
from the standard library.
- Powerful testing framework, vfst .
- Compatibility with github.com/spf13/afero.

Quick start:

Write your code that modifies the filesystem to take a vfs.FS interface 
 that includes almost all 
functions from the standard library's io and ioutil packages and make all 
changes through this interface. For example, replace os.Open with fs.Open.

Create a test virtual filesystem in a few lines of code, for example:

fs, cleanup, err := vfst.NewTestFS(map[string]interface{}{
"/home/user/.bashrc": "# contents of user's .bashrc\n",
})
defer cleanup()

You then pass fs (which implements vfs.FS) to the function that you want to 
test.

After your function has run, you can test properties of the changes, for 
example:

vfst.RunTest(t, fs, "app_conf",
vfst.PathTest("/home/user/app.conf",
vfst.TestModeIsRegular,
vfst.TestModePerm(0644),
vfst.TestContentsString("app config"),
),
)

There's a more complete example 
 
in the docs.

Likely FAQs:

Why not use github.com/spf13/afero? Afero is great, but attempts to provide 
a complete virtual filesystem, including files, and so abstracts os.File to 
afero.File. Sadly, there are many bugs in afero.MemMapFs, and the project 
is not actively maintained. go-vfs is less ambitious, only wrapping the os 
and ioutil functions, and therefore should have fewer bugs.

I already use github.com/spf13/afero, can I use vfst to test my code? Yes, 
there's github.com/twpayne/go-vfsafero for exactly this purpose.

Feedback welcome,
Tom

-- 
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.
For more options, visit https://groups.google.com/d/optout.