Use url.URL with controller-gen - go

I'm trying to develop a custom resource on kubernetes with kubebuilder.
In this CR, I have a field of type url.URL
I get this error :
(*in).DeepCopyInto undefined (type *url.URL has no field or method DeepCopyInto)
Is there a way to work with type url.URL when developing a CR ?
Thanks

So I found a solution
I don't know if it's the best but I've created a custom type URL with the part which is missing to use net/url with controller-gen.
It works fine
https://gist.github.com/quentinalbertone/ec00085b57992d836c08d4586295ace7

Related

Hyperledger Fabic 2.2.0 Error handling success response. Value did not match schema

I am using Hyperledger Fabric 2.2.0 and fabric-network 2.1 (not that important).
My chaincode is written in Go. So I have some structs which have ,omitempty in JSON tag. Here is my struct:
type LeaseDetails struct {
EndOfTerm string `json:"endOfTerm"`
Info string `json:"info,omitempty"`
Option string `json:"option,omitempty"`
}
But I am getting the following error as a return value from my chaincode:
peer=peer0.org1.example.com:7051, status=500, message=Error handling success response. Value did not match schema:
1. return.0.leaseDetails: info,omitempty is required
2. return.0.leaseDetails: option,omitempty is required
If I remove ,omitempty from my struct, and provide default value everything works fine.
In the docs for fabric-contract-api-go it is mentioned that there is some kind of serializer built upon json marshal/unmarshal, but to me it doesn't seem to detect the ,omitempty keyword.
Was this intentional? Or am I missing something here?
Thanks in advance
I got the answer on Hyperledger Chat from user #awjh.
This is as intended, the json is compared against the metadata schema.
By default all fields are required, using omitempty will mean that the
JSON process will remove that field when it has no value. This means a
required field will be missing. To fix this add a metadata tag to mark
the field as optional metadata:",optional"
So in my case, the solution is:
type LeaseDetails struct {
EndOfTerm string `json:"endOfTerm"`
Info string `json:"info,omitempty" metadata:",optional"`
Option string `json:"option,omitempty" metadata:",optional"`
}

Way to convert *grpcpool.ClientConn to *grpc.ClientConn

I am working in golang for the first time and am trying to convert a variable of type *grpcpool.ClientConn to *grpc.ClientConn.
I would like to pass the variable to a function that only takes *grpc.ClientConn. I am using a grpc client stub which requires the *grpc.ClientConn type and I am using processout/grpc-go-pool for the grpc pooling library. I looked at the possibility of making use of Factory in pool.go, but am pretty stuck since that is a type that returns a *grpc.ClientConn.
Does anyone have any suggestions as to how I might be able to make that conversion?
I mean the grpcpool.ClientConn struct is just:
https://godoc.org/github.com/processout/grpc-go-pool#ClientConn
type ClientConn struct {
*grpc.ClientConn
// contains filtered or unexported fields
}
So I'm fairly certain you can just do:
pool := &grpcPool.ClientConn{} // however you get one of these
SomeFunc(pool.ClientConn)
See https://play.golang.org/p/YEzy4Wq8WF9 as an example of getting the embedded struct

How to create a TYPE (UDT) in cassandra using the type name cast. Is it possible to create cast as a type because it is a function?

when creating TYPE in cassandra cli eg: cqlsh: create type cast (name text, role text) i am getting error
" line 1:16 mismatched input '(' expecting '.' (create type
cast[(]...) "
Actually i am using spring boot for creating TYPE in
cassandra-DB. I have tried manually in cassandra cli as well as in spring boot. Both are not working spring boot is throwing exception at the time running the application.
Please refer this link for more clarity ?
http://cassandra.apache.org/doc/latest/cql/functions.html
please help me on this.
Every object in Cassandra need to be defined in some keyspace. You either need to specify the full type name in form of keyspace.name, or execute use keyspace; before executing this command.
Looks like a bug in Cassandra (feel free to file a JIRA), if you really need to use that name, you can try to specify it as:
create type test."cast"(...
but in this case, the name of the type will be case sensitive, and you'll need always specify it in double quotes.

Why is possible to pass parameters to a type like in http.Dir(".")?

In http package it is defined a custom type (type Dir string) and then a method Open is added to it (https://golang.org/src/net/http/fs.go#L34). When invoked elsewhere it is done by http.Dir(".") as it were a function or method. Can someone explain me why and what is happening here?
http.Dir(".") is a type conversion. It converts the string "." to type http.Dir.

ResourceManager.GetString() not returning value

I am trying to implement multiple language support for my web project. I am new to it.
I am not able to get the resource file value by using ResourceManager.GetString() function. I am passing the name and current CuluralInfo. The resource file present in my App_GlobalResources are Sample.resx, Sample.en-us.resx, Sample.zh-cn.resx and Sample.ar-sa.resx. I am having a name field named "Heading1" and its value in all the resource files
My code is like
string Heading1= Resources.Global.ResourceManager.GetString(("Heading1", Thread.CurrentThread.CurrentCulture);
But it is always returning null value. Please help me to get the solution for this problem
Thanks
San
I found the problem
The code should be like
string Heading1= Resources.Sample.ResourceManager.GetString(name, culture_object);

Resources