mirror of
https://github.com/xxjwxc/ginrpc.git
synced 2025-09-27 03:26:05 +08:00
rebase
This commit is contained in:
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
234
README.md
234
README.md
@@ -1,78 +1,196 @@
|
||||
# go-restful
|
||||
- 基于 [go-gin](https://github.com/gin-gonic/gin) 的 json restful 风格的golang基础库
|
||||
[](https://travis-ci.org/xxjwxc/ginrpc)
|
||||
[](https://goreportcard.com/report/github.com/xxjwxc/ginrpc)
|
||||
[](https://codecov.io/gh/xxjwxc/ginrpc)
|
||||
[](https://godoc.org/github.com/xxjwxc/ginrpc)
|
||||
[](https://github.com/avelino/awesome-go)
|
||||
|
||||
1、 目录结构说明
|
||||
# [中文文档](README_cn.md)
|
||||
|
||||
- ginrpc/base/common.go 基础库
|
||||
- ginrpc/base/api/context.go 自定义context内容
|
||||
## Automatic parameter binding base on [go-gin](https://github.com/gin-gonic/gin)
|
||||
|
||||

|
||||
|
||||
## doc
|
||||
|
||||

|
||||
|
||||
|
||||
2、api接口说明
|
||||
## Golang gin automatic parameter binding
|
||||
|
||||
### 支持3种接口模式
|
||||
- Support for RPC automatic mapping
|
||||
- Support object registration
|
||||
- Support annotation routing
|
||||
- base on [go-gin](https://github.com/gin-gonic/gin) on json restful style
|
||||
- implementation of parameter filtering and binding with request
|
||||
- code registration simple and supports multiple ways of registration
|
||||
- [grpc-go](https://github.com/grpc/grpc-go) bind support
|
||||
- Support [swagger](http://editor.swagger.io/) [MORE](https://github.com/xxjwxc/gmsec)
|
||||
- Support [markdown/mindoc](https://www.iminho.me/) [MORE](https://github.com/xxjwxc/gmsec)
|
||||
|
||||
- 1. func(*gin.Context) //gogin 原始接口
|
||||
- 2. func(*api.Context) //自定义的context类型
|
||||
- 3. func(*api.Context,req) //自定义的context类型,带request 请求参数
|
||||
func(*gin.Context,*req)
|
||||
...... 等接口模式
|
||||
- [DEMO](https://github.com/xxjwxc/gmsec)
|
||||
|
||||
### 示例代码
|
||||
## API details
|
||||
|
||||
### Three interface modes are supported
|
||||
|
||||
- func(*gin.Context) // go-gin Raw interface
|
||||
|
||||
func(*api.Context) // Custom context type
|
||||
|
||||
- func(*api.Context,req) // Custom context type,with request
|
||||
|
||||
func(*api.Context,*req)
|
||||
|
||||
- func(*gin.Context,*req) // go-gin context,with request
|
||||
|
||||
func(*gin.Context,req)
|
||||
|
||||
- func(*gin.Context,*req)(*resp,error) // go-gin context,with request,return parameter and error ==> [grpc-go](https://github.com/grpc/grpc-go)
|
||||
|
||||
func(*gin.Context,req)(resp,error)
|
||||
|
||||
## 一 Parameter auto binding,Object registration (annotation routing)
|
||||
|
||||
### Initialization project (this project is named after `ginweb`)
|
||||
``` go mod init ginweb ```
|
||||
|
||||
### coding [more>>](https://github.com/xxjwxc/ginrpc/tree/master/sample/ginweb)
|
||||
```go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
_ "ginweb/routers" // Debug mode requires adding [mod] / routes to register annotation routes.debug模式需要添加[mod]/routers 注册注解路由
|
||||
"github.com/xxjwxc/public/mydoc/myswagger" // swagger 支持
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
)
|
||||
|
||||
type ReqTest struct {
|
||||
Access_token string `json:"access_token"`
|
||||
UserName string `json:"user_name" binding:"required"` // With verification mode
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
// Hello ...
|
||||
type Hello struct {
|
||||
}
|
||||
|
||||
// Hello Annotated route (bese on beego way)
|
||||
// @Router /block [post,get]
|
||||
func (s *Hello) Hello(c *api.Context, req *ReqTest) {
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
// Hello2 Route without annotation (the parameter is 2 default post)
|
||||
func (s *Hello) Hello2(c *gin.Context, req ReqTest) {
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
// [grpc-go](https://github.com/grpc/grpc-go)
|
||||
// with request,return parameter and error
|
||||
// TestFun6 Route without annotation (the parameter is 2 default post)
|
||||
func TestFun6(c *gin.Context, req ReqTest) (*ReqTest, error) {
|
||||
fmt.Println(req)
|
||||
//c.JSON(http.StatusOK, req)
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// swagger
|
||||
myswagger.SetHost("https://localhost:8080")
|
||||
myswagger.SetBasePath("gmsec")
|
||||
myswagger.SetSchemes(true, false)
|
||||
// -----end --
|
||||
base := ginrpc.New(ginrpc.WithGroup("xxjwxc"))
|
||||
router := gin.Default()
|
||||
base.Register(router, new(Hello)) // object register like(go-micro)
|
||||
router.POST("/test6", base.HandlerFunc(TestFun6)) // function register
|
||||
base.RegisterHandlerFunc(router, []string{"post", "get"}, "/test", TestFun6)
|
||||
router.Run(":8080")
|
||||
}
|
||||
```
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
### - Annotation routing related instructions
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xie1xiao1jun/ginrpc/base"
|
||||
"github.com/xie1xiao1jun/ginrpc/base/api"
|
||||
)
|
||||
type ReqTest struct {
|
||||
Access_token string `json:"access_token"` //access_token
|
||||
UserName string `json:"user_name" binding:"required"` //用户名
|
||||
Password string `json:"password"` //新密码
|
||||
}
|
||||
```
|
||||
// @Router /block [post,get]
|
||||
|
||||
//TestFun1 gin 默认的函数回调地址
|
||||
func TestFun1(c *gin.Context) {
|
||||
fmt.Println(c.Params)
|
||||
c.String(200, "ok")
|
||||
}
|
||||
@Router tag /block router [post,get] method
|
||||
|
||||
//TestFun2 自定义context的函数回调地址
|
||||
func TestFun2(c *api.Context) {
|
||||
fmt.Println(c.Params)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
```
|
||||
|
||||
//TestFun3 带自定义context跟已解析的req参数回调方式
|
||||
func TestFun3(c *api.Context, req *ReqTest) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
#### Note: if there is no annotation route in the object function, the system will add annotation route by default. Post mode: with req (2 parameters (CTX, req)), get mode is a parameter (CTX)
|
||||
|
||||
//TestFun3 带自定义context跟已解析的req参数回调方式
|
||||
func TestFun4(c *gin.Context, req ReqTest) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
|
||||
c.JSON(http.StatusOK, req)
|
||||
}
|
||||
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
router.POST("/test1", base.GetHandlerFunc(TestFun1))
|
||||
router.POST("/test2", base.GetHandlerFunc(TestFun2))
|
||||
router.POST("/test3", base.GetHandlerFunc(TestFun3))
|
||||
router.POST("/test4", base.GetHandlerFunc(TestFun4))
|
||||
### 1. Annotation route will automatically create `[mod]/routes/gen_router.go` file, which needs to be added when calling:
|
||||
|
||||
router.Run(":8080")
|
||||
}
|
||||
```
|
||||
_ "[mod]/routers" // Debug mode requires adding [mod] / routes to register annotation routes
|
||||
|
||||
......
|
||||
```
|
||||
|
||||
```
|
||||
By default, the [gen_router. Data] file will also be generated in the root directory of the project (keep this file, and you can embed it without adding the above code)
|
||||
|
||||
### 2. way of annotation route :
|
||||
|
||||
more to saying [ginweb](/sample/ginweb)
|
||||
|
||||
### 3. Parameter description
|
||||
|
||||
ginrpc.WithCtx : Set custom context
|
||||
|
||||
ginrpc.WithDebug(true) : Set debug mode
|
||||
|
||||
ginrpc.WithGroup("xxjwxc") : Add routing prefix (you can also use gin. Group grouping)
|
||||
|
||||
ginrpc.WithBigCamel(true) : Set big camel standard (false is web mode, _, lowercase)
|
||||
|
||||
[more>>](https://godoc.org/github.com/xxjwxc/ginrpc)
|
||||
|
||||
### 4. Execute curl to automatically bind parameters. See the results directly
|
||||
|
||||
```
|
||||
curl 'http://127.0.0.1:8080/xxjwxc/block' -H 'Content-Type: application/json' -d '{"access_token":"111", "user_name":"222", "password":"333"}'
|
||||
```
|
||||
|
||||
```
|
||||
curl 'http://127.0.0.1:8080/xxjwxc/hello.hello2' -H 'Content-Type: application/json' -d '{"access_token":"111", "user_name":"222", "password":"333"}'
|
||||
```
|
||||
|
||||
## 二. swagger/markdown/mindoc Document generation description
|
||||
|
||||
### 1.For object registration 'ginrpc. Register' mode, document export is supported
|
||||
### 2.Export supports annotation routing, Parameter annotation and default value (` tag '. ` default')
|
||||
### 3.Default export path:(`/docs/swagger/swagger.json`,`/docs/markdown`)
|
||||
### 4 struct demo
|
||||
```
|
||||
type ReqTest struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
UserName string `json:"user_name" binding:"required"` // 带校验方式
|
||||
Password string `json:"password"`
|
||||
}
|
||||
```
|
||||
- [more >>>](https://github.com/xxjwxc/gmsec)
|
||||
|
||||
## Stargazers over time
|
||||
|
||||
[](https://starchart.cc/xxjwxc/ginrpc)
|
||||
|
||||
|
||||
## Next
|
||||
|
||||
1. Export API documents
|
||||
|
||||
2. Export postman test configuration
|
||||
|
||||
### coding address:[ginprc](https://github.com/xxjwxc/ginrpc) Please give star support
|
186
README_cn.md
Normal file
186
README_cn.md
Normal file
@@ -0,0 +1,186 @@
|
||||
[](https://travis-ci.org/xxjwxc/ginrpc)
|
||||
[](https://goreportcard.com/report/github.com/xxjwxc/ginrpc)
|
||||
[](https://codecov.io/gh/xxjwxc/ginrpc)
|
||||
[](https://godoc.org/github.com/xxjwxc/ginrpc)
|
||||
[](https://github.com/avelino/awesome-go)
|
||||
# [English](README.md)
|
||||
|
||||
## [ginprc](https://github.com/xxjwxc/ginrpc) 注解路由,自动参数绑定工具
|
||||
|
||||

|
||||
|
||||
## doc
|
||||
|
||||

|
||||
|
||||
|
||||
## golang gin 参数自动绑定工具
|
||||
- 支持对象自动注册及注解路由
|
||||
- 支持参数自动绑定
|
||||
- 自带请求参数过滤及绑定实现 binding:"required" [validator](go-playground/validator.v8)
|
||||
- 支持 [grpc-go](https://github.com/grpc/grpc-go) 绑定模式
|
||||
- 支持[swagger 文档](http://editor.swagger.io/)导出 [MORE](https://github.com/gmsec/gmsec)
|
||||
- 支持[markdown/mindoc 文档](https://www.iminho.me/)导出 [MORE](https://github.com/gmsec/gmsec)
|
||||
|
||||
- [更多请看](https://github.com/gmsec/gmsec)
|
||||
|
||||
### 支持多种接口模式
|
||||
|
||||
- func(*gin.Context) //go-gin 原始接口
|
||||
|
||||
func(*api.Context) //自定义的context类型
|
||||
|
||||
- func(*api.Context,req) //自定义的context类型,带request 请求参数
|
||||
|
||||
- func(*gin.Context,*req) //go-gin context类型,带request 请求参数
|
||||
|
||||
- func(*gin.Context,*req)(*resp,error) //go-gin context类型,带request 请求参数,带错误返回参数 ==> [grpc-go](https://github.com/grpc/grpc-go)
|
||||
|
||||
func(*gin.Context,req)(resp,error)
|
||||
|
||||
## 一. 参数自动绑定/对象注册(注解路由)
|
||||
|
||||
### 初始化项目(本项目以ginweb 为名字)
|
||||
|
||||
` go mod init ginweb `
|
||||
|
||||
### 代码
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
_ "ginweb/routers" // debug模式需要添加[mod]/routers 注册注解路由
|
||||
"github.com/xxjwxc/public/mydoc/myswagger" // swagger 支持
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
)
|
||||
|
||||
type ReqTest struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
UserName string `json:"user_name" binding:"required"` // 带校验方式
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type Hello struct {
|
||||
}
|
||||
|
||||
// Hello 带注解路由(参考beego形式)
|
||||
// @Router /block [post,get]
|
||||
func (s *Hello) Hello(c *api.Context, req *ReqTest) {
|
||||
fmt.Println(req)
|
||||
c.WriteJSON(req) // 返回结果
|
||||
}
|
||||
|
||||
// Hello2 不带注解路由(参数为2默认post)
|
||||
func (s *Hello) Hello2(c *gin.Context, req ReqTest) {
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, "ok") // gin 默认返回结果
|
||||
}
|
||||
|
||||
// Hello3 [grpc-go](https://github.com/grpc/grpc-go) 模式
|
||||
func (s *Hello) Hello3(c *gin.Context, req ReqTest) (*ReqTest, error) {
|
||||
fmt.Println(req)
|
||||
return &req,nil
|
||||
}
|
||||
|
||||
//TestFun6 带自定义context跟已解析的req参数回调方式,err,resp 返回模式
|
||||
func TestFun6(c *gin.Context, req ReqTest) (*ReqTest, error) {
|
||||
fmt.Println(req)
|
||||
//c.JSON(http.StatusOK, req)
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
// swagger
|
||||
myswagger.SetHost("https://localhost:8080")
|
||||
myswagger.SetBasePath("gmsec")
|
||||
myswagger.SetSchemes(true, false)
|
||||
// -----end --
|
||||
base := ginrpc.New(ginrpc.WithGroup("xxjwxc"))
|
||||
router := gin.Default()
|
||||
base.Register(router, new(Hello)) // 对象注册 like(go-micro)
|
||||
router.POST("/test6", base.HandlerFunc(TestFun6)) // 函数注册
|
||||
base.RegisterHandlerFunc(router, []string{"post", "get"}, "/test", TestFun6) // 多种请求方式注册
|
||||
router.Run(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
[更多>>](https://github.com/xxjwxc/ginrpc/tree/master/sample/ginweb)
|
||||
|
||||
### 执行curl,可以自动参数绑定。直接看结果
|
||||
|
||||
```
|
||||
curl 'http://127.0.0.1:8080/xxjwxc/block' -H 'Content-Type: application/json' -d '{"access_token":"111", "user_name":"222", "password":"333"}'
|
||||
```
|
||||
|
||||
```
|
||||
curl 'http://127.0.0.1:8080/xxjwxc/hello.hello2' -H 'Content-Type: application/json' -d '{"access_token":"111", "user_name":"222", "password":"333"}'
|
||||
```
|
||||
|
||||
------------------------------------------------------
|
||||
|
||||
### -注解路由相关说明
|
||||
|
||||
```
|
||||
// @Router /block [post,get]
|
||||
@Router 标记 /block 路由 [post,get] method 调用方式
|
||||
|
||||
```
|
||||
|
||||
#### 说明:如果对象函数中不加注解路由,系统会默认添加注解路由。post方式:带req(2个参数(ctx,req)),get方式为一个参数(ctx)
|
||||
|
||||
### 1. 注解路由会自动创建[root]/routers/gen_router.go 文件 需要在调用时加:
|
||||
|
||||
```
|
||||
_ "[mod]/routers" // debug模式需要添加[mod]/routers 注册注解路由
|
||||
```
|
||||
|
||||
默认也会在项目根目录生成 `gen_router.data` 文件(保留此文件,可以不用添加上面代码嵌入)
|
||||
|
||||
### 2. 注册函数说明
|
||||
|
||||
ginrpc.WithCtx : 设置自定义context
|
||||
|
||||
ginrpc.WithDebug(true) : 设置debug模式
|
||||
|
||||
ginrpc.WithGroup("xxjwxc") : 添加路由前缀 (也可以使用gin.Group 分组)
|
||||
|
||||
ginrpc.WithBigCamel(true) : 设置大驼峰标准(false 为web模式,_,小写)
|
||||
|
||||
[更多>>](https://godoc.org/github.com/xxjwxc/ginrpc)
|
||||
|
||||
### 2. 注解路由调用demo:[ginweb](/sample/ginweb)
|
||||
|
||||
### 3. 支持绑定grpc函数: [ginweb](/sample/ginweb)
|
||||
|
||||
## 二. swagger/markdown/mindoc 文档生成说明
|
||||
|
||||
### 1.对于对象注册`ginrpc.Register`模式,支持文档导出
|
||||
### 2.导出支持注解路由,支持参数注释,支持默认值(`tag`.`default`)
|
||||
### 3.默认导出路径:(`/docs/swagger/swagger.json`,`/docs/markdown`)
|
||||
### 4 struct demo
|
||||
```
|
||||
type ReqTest struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
UserName string `json:"user_name" binding:"required"` // 带校验方式
|
||||
Password string `json:"password"`
|
||||
}
|
||||
```
|
||||
|
||||
- [更多 >>>](https://github.com/xxjwxc/gmsec)
|
||||
|
||||
|
||||
## Stargazers over time
|
||||
|
||||
[](https://starchart.cc/xxjwxc/ginrpc)
|
||||
|
||||
## 下一步
|
||||
|
||||
- 添加服务发现
|
||||
|
||||
### 代码地址: [ginprc](https://github.com/xxjwxc/ginrpc) 如果喜欢请给星支持
|
31
api/context.go
Normal file
31
api/context.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Package api The next version of the underlying category will support automatic parsing of a single struct.
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Context Wrapping gin context to custom context
|
||||
type Context struct { // 包装gin的上下文到自定义context
|
||||
*gin.Context
|
||||
}
|
||||
|
||||
// GetVersion Get the version by req url
|
||||
func (c *Context) GetVersion() string { // 获取版本号
|
||||
return c.Param("version")
|
||||
}
|
||||
|
||||
//WriteJSON 写入json对象
|
||||
func (c *Context) WriteJSON(obj interface{}) {
|
||||
c.JSON(200, obj)
|
||||
}
|
||||
|
||||
// NewCtx Create a new custom context
|
||||
func NewCtx(c *gin.Context) *Context { // 新建一个自定义context
|
||||
return &Context{c}
|
||||
}
|
||||
|
||||
// NewAPIFunc default of custom handlefunc
|
||||
func NewAPIFunc(c *gin.Context) interface{} {
|
||||
return NewCtx(c)
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
package api
|
||||
|
||||
/*
|
||||
* 基础类目 下一个版本将支持 单个struct 自动解析。
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
*gin.Context
|
||||
}
|
||||
|
||||
//
|
||||
func Newctx(c *gin.Context) *Context {
|
||||
return &Context{c}
|
||||
}
|
||||
|
||||
//获取版本号
|
||||
func (c *Context) GetVersion() string {
|
||||
return c.Param("version")
|
||||
}
|
||||
|
||||
//获取用户信息
|
159
base/common.go
159
base/common.go
@@ -1,159 +0,0 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"runtime"
|
||||
|
||||
"github.com/xie1xiao1jun/ginrpc/base/api"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
/*
|
||||
说明:支持3种类型的接口
|
||||
func(*gin.Context) //gogin 原始接口
|
||||
func(*Context) //自定义的context类型
|
||||
func(*Context,req) //自定义的context类型,带request 请求参数
|
||||
*/
|
||||
// type handlerFunc1 func(*gin.Context)
|
||||
// type handlerFunc2 func(*api.Context)
|
||||
// type handlerFunc3 func(*api.Context, interface{})
|
||||
|
||||
func _fun1(*gin.Context) {}
|
||||
func _fun2(*api.Context) {}
|
||||
func _fun3(*api.Context, interface{}) {}
|
||||
|
||||
// var fun1 handlerFunc1
|
||||
// var fun2 handlerFunc2
|
||||
// var fun3 handlerFunc3
|
||||
|
||||
func GetHandlerFunc(handlerFunc interface{}) gin.HandlerFunc {
|
||||
//gin默认方法
|
||||
if reflect.TypeOf(handlerFunc) == reflect.TypeOf(_fun1) {
|
||||
return handlerFunc.(func(*gin.Context)) //可以添加func 包装调用前后
|
||||
}
|
||||
|
||||
//自定义的context
|
||||
if reflect.TypeOf(handlerFunc) == reflect.TypeOf(_fun2) {
|
||||
method := reflect.ValueOf(handlerFunc)
|
||||
return func(c *gin.Context) {
|
||||
method.Call([]reflect.Value{reflect.ValueOf(api.Newctx(c))})
|
||||
}
|
||||
|
||||
// 带 struct 定义
|
||||
// method := reflect.TypeOf(handlerFunc).Method(0)
|
||||
// return func(c *gin.Context) {
|
||||
// method.Func.Call([]reflect.Value{reflect.ValueOf(api.Newctx(c))})
|
||||
// }
|
||||
}
|
||||
|
||||
//自定义的context类型,带request 请求参数
|
||||
call, err := getCallFunc3(handlerFunc)
|
||||
|
||||
if err != nil { //直接
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return call
|
||||
}
|
||||
|
||||
//
|
||||
func getCallFunc3(handlerFunc interface{}) (func(*gin.Context), error) {
|
||||
typ := reflect.ValueOf(handlerFunc).Type()
|
||||
if typ.NumIn() != 2 { //参数检查
|
||||
return nil, errors.New("method " + runtime.FuncForPC(reflect.ValueOf(handlerFunc).Pointer()).Name() + " not support!")
|
||||
}
|
||||
|
||||
var ctxType, reqType reflect.Type
|
||||
ctxType = typ.In(0)
|
||||
reqType = typ.In(1)
|
||||
reqIsGinCtx := false
|
||||
if ctxType != reflect.TypeOf(&gin.Context{}) &&
|
||||
ctxType != reflect.TypeOf(&api.Context{}) {
|
||||
return nil, errors.New("method " + runtime.FuncForPC(reflect.ValueOf(handlerFunc).Pointer()).Name() + " first parm not support!")
|
||||
}
|
||||
|
||||
if ctxType == reflect.TypeOf(&gin.Context{}) {
|
||||
reqIsGinCtx = true
|
||||
}
|
||||
|
||||
reqIsValue := true //
|
||||
if reqType.Kind() == reflect.Ptr {
|
||||
reqIsValue = false
|
||||
}
|
||||
|
||||
method := reflect.ValueOf(handlerFunc)
|
||||
return func(c *gin.Context) {
|
||||
var req reflect.Value
|
||||
if reqIsValue {
|
||||
req = reflect.New(reqType)
|
||||
} else {
|
||||
req = reflect.New(reqType.Elem())
|
||||
}
|
||||
|
||||
if err := unmarshal(c, req.Interface()); err != nil { //返回错误信息
|
||||
c.JSON(http.StatusBadRequest, gin.H{"state": false, "code": 1001, "error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if reqIsValue {
|
||||
req = req.Elem()
|
||||
}
|
||||
|
||||
if reqIsGinCtx {
|
||||
method.Call([]reflect.Value{reflect.ValueOf(c), req})
|
||||
} else {
|
||||
method.Call([]reflect.Value{reflect.ValueOf(api.Newctx(c)), req})
|
||||
}
|
||||
|
||||
}, nil
|
||||
}
|
||||
|
||||
// func getCallFunc3(handlerFunc interface{}) (func(*gin.Context), error) {
|
||||
// typ := reflect.TypeOf(handlerFunc).Method(0)
|
||||
// mt := typ.Type
|
||||
// if mt.NumIn() != 2 { //参数检查
|
||||
// return nil, errors.New("method " + reflect.ValueOf(handlerFunc).Type().Name() + " not support!")
|
||||
// }
|
||||
|
||||
// var ctxType, reqType reflect.Type
|
||||
// ctxType = mt.In(0)
|
||||
// reqType = mt.In(1)
|
||||
// if reflect.TypeOf(ctxType) != reflect.TypeOf(&gin.Context{}) &&
|
||||
// reflect.TypeOf(ctxType) != reflect.TypeOf(&api.Context{}) {
|
||||
// return nil, errors.New("method " + reflect.ValueOf(handlerFunc).Type().Name() + " first parm not support!")
|
||||
// }
|
||||
|
||||
// reqIsValue := false //
|
||||
// if reqType.Kind() == reflect.Ptr {
|
||||
// reqIsValue = true
|
||||
// } else {
|
||||
// reqIsValue = false
|
||||
// }
|
||||
// method := reflect.TypeOf(handlerFunc).Method(0)
|
||||
// return func(c *gin.Context) {
|
||||
// var req reflect.Value
|
||||
// if reqIsValue {
|
||||
// req = reflect.New(reqType.Elem())
|
||||
// } else {
|
||||
// req = reflect.New(reqType)
|
||||
// }
|
||||
|
||||
// if err := unmarshal(c, req.Interface()); err != nil { //返回错误信息
|
||||
// c.JSON(200, message.GetErrorMsg(message.ParameterInvalid, err))
|
||||
// return
|
||||
// }
|
||||
|
||||
// if reqIsValue {
|
||||
// req = req.Elem()
|
||||
// }
|
||||
|
||||
// method.Func.Call([]reflect.Value{reflect.ValueOf(api.Newctx(c)), req})
|
||||
// }, nil
|
||||
// }
|
||||
|
||||
func unmarshal(c *gin.Context, v interface{}) error {
|
||||
return c.ShouldBind(v)
|
||||
}
|
435
common.go
Normal file
435
common.go
Normal file
@@ -0,0 +1,435 @@
|
||||
package ginrpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/xxjwxc/public/errors"
|
||||
"github.com/xxjwxc/public/message"
|
||||
"github.com/xxjwxc/public/myast"
|
||||
"github.com/xxjwxc/public/mybigcamel"
|
||||
"github.com/xxjwxc/public/mydoc"
|
||||
"github.com/xxjwxc/public/myreflect"
|
||||
)
|
||||
|
||||
func (b *_Base) parseReqResp(typ reflect.Type, isObj bool) (reflect.Type, reflect.Type) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// checkHandlerFunc Judge whether to match rules
|
||||
func (b *_Base) checkHandlerFunc(typ reflect.Type, isObj bool) (int, bool) { // 判断是否匹配规则,返回参数个数
|
||||
offset := 0
|
||||
if isObj {
|
||||
offset = 1
|
||||
}
|
||||
num := typ.NumIn() - offset
|
||||
if num == 1 || num == 2 { // Parameter checking 参数检查
|
||||
ctxType := typ.In(0 + offset)
|
||||
|
||||
// go-gin default method
|
||||
if ctxType == reflect.TypeOf(&gin.Context{}) {
|
||||
return num, true
|
||||
}
|
||||
|
||||
// Customized context . 自定义的context
|
||||
if ctxType == b.apiType {
|
||||
return num, true
|
||||
}
|
||||
}
|
||||
return num, false
|
||||
}
|
||||
|
||||
// HandlerFunc Get and filter the parameters to be bound (object call type)
|
||||
func (b *_Base) handlerFuncObj(tvl, obj reflect.Value) gin.HandlerFunc { // 获取并过滤要绑定的参数(obj 对象类型)
|
||||
typ := tvl.Type()
|
||||
if typ.NumIn() == 2 { // Parameter checking 参数检查
|
||||
ctxType := typ.In(1)
|
||||
|
||||
// go-gin default method
|
||||
apiFun := func(c *gin.Context) interface{} { return c }
|
||||
if ctxType == b.apiType { // Customized context . 自定义的context
|
||||
apiFun = b.apiFun
|
||||
} else if !(ctxType == reflect.TypeOf(&gin.Context{})) {
|
||||
panic("method " + runtime.FuncForPC(tvl.Pointer()).Name() + " not support!")
|
||||
}
|
||||
|
||||
return func(c *gin.Context) {
|
||||
tvl.Call([]reflect.Value{obj, reflect.ValueOf(apiFun(c))})
|
||||
}
|
||||
}
|
||||
|
||||
// Custom context type with request parameters .自定义的context类型,带request 请求参数
|
||||
call, err := b.getCallFunc3(tvl, obj)
|
||||
if err != nil { // Direct reporting error.
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return call
|
||||
}
|
||||
|
||||
// Custom context type with request parameters
|
||||
func (b *_Base) getCallFunc3(tvls ...reflect.Value) (func(*gin.Context), error) {
|
||||
offset := 0
|
||||
if len(tvls) > 1 {
|
||||
offset = 1
|
||||
}
|
||||
|
||||
tvl := tvls[0]
|
||||
typ := tvl.Type()
|
||||
if typ.NumIn() != (2 + offset) { // Parameter checking 参数检查
|
||||
return nil, errors.New("method " + runtime.FuncForPC(tvl.Pointer()).Name() + " not support!")
|
||||
}
|
||||
|
||||
if typ.NumOut() != 0 {
|
||||
if typ.NumOut() == 2 { // Parameter checking 参数检查
|
||||
if returnType := typ.Out(1); returnType != typeOfError {
|
||||
return nil, errors.Errorf("method : %v , returns[1] %v not error",
|
||||
runtime.FuncForPC(tvl.Pointer()).Name(), returnType.String())
|
||||
}
|
||||
} else {
|
||||
return nil, errors.Errorf("method : %v , Only 2 return values (obj, error) are supported", runtime.FuncForPC(tvl.Pointer()).Name())
|
||||
}
|
||||
}
|
||||
|
||||
ctxType, reqType := typ.In(0+offset), typ.In(1+offset)
|
||||
|
||||
reqIsGinCtx := false
|
||||
if ctxType == reflect.TypeOf(&gin.Context{}) {
|
||||
reqIsGinCtx = true
|
||||
}
|
||||
|
||||
// ctxType != reflect.TypeOf(gin.Context{}) &&
|
||||
// ctxType != reflect.Indirect(reflect.ValueOf(b.iAPIType)).Type()
|
||||
if !reqIsGinCtx && ctxType != b.apiType {
|
||||
return nil, errors.New("method " + runtime.FuncForPC(tvl.Pointer()).Name() + " first parm not support!")
|
||||
}
|
||||
|
||||
reqIsValue := true
|
||||
if reqType.Kind() == reflect.Ptr {
|
||||
reqIsValue = false
|
||||
}
|
||||
apiFun := func(c *gin.Context) interface{} { return c }
|
||||
if !reqIsGinCtx {
|
||||
apiFun = b.apiFun
|
||||
}
|
||||
|
||||
return func(c *gin.Context) {
|
||||
req := reflect.New(reqType)
|
||||
if reqIsValue {
|
||||
req = reflect.New(reqType)
|
||||
} else {
|
||||
req = reflect.New(reqType.Elem())
|
||||
}
|
||||
if err := b.unmarshal(c, req.Interface()); err != nil { // Return error message.返回错误信息
|
||||
var fields []string
|
||||
if _, ok := err.(validator.ValidationErrors); ok {
|
||||
for _, err := range err.(validator.ValidationErrors) {
|
||||
tmp := fmt.Sprintf("%v:%v", myreflect.FindTag(req.Interface(), err.Field(), "json"), err.Tag())
|
||||
if len(err.Param()) > 0 {
|
||||
tmp += fmt.Sprintf("[%v](but[%v])", err.Param(), err.Value())
|
||||
}
|
||||
fields = append(fields, tmp)
|
||||
// fmt.Println(err.Namespace())
|
||||
// fmt.Println(err.Field())
|
||||
// fmt.Println(err.StructNamespace()) // can differ when a custom TagNameFunc is registered or
|
||||
// fmt.Println(err.StructField()) // by passing alt name to ReportError like below
|
||||
// fmt.Println(err.Tag())
|
||||
// fmt.Println(err.ActualTag())
|
||||
// fmt.Println(err.Kind())
|
||||
// fmt.Println(err.Type())
|
||||
// fmt.Println(err.Value())
|
||||
// fmt.Println(err.Param())
|
||||
// fmt.Println()
|
||||
}
|
||||
} else if _, ok := err.(*json.UnmarshalTypeError); ok {
|
||||
err := err.(*json.UnmarshalTypeError)
|
||||
tmp := fmt.Sprintf("%v:%v(but[%v])", err.Field, err.Type.String(), err.Value)
|
||||
fields = append(fields, tmp)
|
||||
|
||||
} else {
|
||||
fields = append(fields, err.Error())
|
||||
}
|
||||
|
||||
msg := message.GetErrorMsg(message.ParameterInvalid)
|
||||
msg.Error = fmt.Sprintf("req param : %v", strings.Join(fields, ";"))
|
||||
c.JSON(http.StatusBadRequest, msg)
|
||||
return
|
||||
}
|
||||
|
||||
if reqIsValue {
|
||||
req = req.Elem()
|
||||
}
|
||||
var returnValues []reflect.Value
|
||||
if offset > 0 {
|
||||
returnValues = tvl.Call([]reflect.Value{tvls[1], reflect.ValueOf(apiFun(c)), req})
|
||||
} else {
|
||||
returnValues = tvl.Call([]reflect.Value{reflect.ValueOf(apiFun(c)), req})
|
||||
}
|
||||
if returnValues != nil {
|
||||
obj := returnValues[0].Interface()
|
||||
rerr := returnValues[1].Interface()
|
||||
if rerr != nil {
|
||||
msg := message.GetErrorMsg(message.InValidOp)
|
||||
msg.Error = rerr.(error).Error()
|
||||
c.JSON(http.StatusBadRequest, msg)
|
||||
} else {
|
||||
c.JSON(http.StatusOK, obj)
|
||||
}
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (b *_Base) unmarshal(c *gin.Context, v interface{}) error {
|
||||
return c.ShouldBind(v)
|
||||
}
|
||||
|
||||
func (b *_Base) parserStruct(req, resp *parmInfo, astPkg *ast.Package, modPkg, modFile string) (r, p *mydoc.StructInfo) {
|
||||
ant := myast.NewStructAnalys(modPkg, modFile)
|
||||
if req != nil {
|
||||
tmp := astPkg
|
||||
if len(req.Pkg) > 0 {
|
||||
objFile := myast.EvalSymlinks(modPkg, modFile, req.Import)
|
||||
tmp, _ = myast.GetAstPkgs(req.Pkg, objFile) // get ast trees.
|
||||
}
|
||||
r = ant.ParserStruct(tmp, req.Type)
|
||||
}
|
||||
|
||||
if resp != nil {
|
||||
tmp := astPkg
|
||||
if len(resp.Pkg) > 0 {
|
||||
objFile := myast.EvalSymlinks(modPkg, modFile, resp.Import)
|
||||
tmp, _ = myast.GetAstPkgs(resp.Pkg, objFile) // get ast trees.
|
||||
}
|
||||
p = ant.ParserStruct(tmp, resp.Type)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var routeRegex = regexp.MustCompile(`@Router\s+(\S+)(?:\s+\[(\S+)\])?`)
|
||||
|
||||
func (b *_Base) parserComments(f *ast.FuncDecl, objName, objFunc string, imports map[string]string, objPkg string, num int) ([]genComment, *parmInfo, *parmInfo) {
|
||||
var note string
|
||||
var gcs []genComment
|
||||
var req, resp *parmInfo
|
||||
if f.Type.Params != nil {
|
||||
if f.Type.Params.NumFields() > 1 {
|
||||
req = &parmInfo{}
|
||||
d := f.Type.Params.List[1].Type
|
||||
switch exp := d.(type) {
|
||||
case *ast.SelectorExpr: // 非本文件包
|
||||
req.Type = exp.Sel.Name
|
||||
if x, ok := exp.X.(*ast.Ident); ok {
|
||||
req.Import = imports[x.Name]
|
||||
req.Pkg = myast.GetImportPkg(req.Import)
|
||||
}
|
||||
case *ast.StarExpr: // 本文件
|
||||
if x, ok := exp.X.(*ast.Ident); ok {
|
||||
req.Type = x.Name
|
||||
req.Import = objPkg // 本包
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if f.Type.Results != nil {
|
||||
if f.Type.Results.NumFields() > 1 {
|
||||
resp = &parmInfo{}
|
||||
d := f.Type.Results.List[0].Type
|
||||
if exp, ok := d.(*ast.StarExpr); ok {
|
||||
switch expx := exp.X.(type) {
|
||||
case *ast.SelectorExpr: // 非本地包
|
||||
resp.Type = expx.Sel.Name
|
||||
if x, ok := expx.X.(*ast.Ident); ok {
|
||||
resp.Pkg = x.Name
|
||||
resp.Import = imports[resp.Pkg]
|
||||
}
|
||||
case *ast.Ident: // 本文件
|
||||
resp.Type = expx.Name
|
||||
resp.Import = objPkg // 本包
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if f.Doc != nil {
|
||||
for _, c := range f.Doc.List {
|
||||
gc := genComment{}
|
||||
t := strings.TrimSpace(strings.TrimPrefix(c.Text, "//"))
|
||||
if strings.HasPrefix(t, "@Router") {
|
||||
// t := strings.TrimSpace(strings.TrimPrefix(c.Text, "//"))
|
||||
matches := routeRegex.FindStringSubmatch(t)
|
||||
if len(matches) == 3 {
|
||||
gc.RouterPath = matches[1]
|
||||
methods := matches[2]
|
||||
if methods == "" {
|
||||
gc.Methods = []string{"get"}
|
||||
} else {
|
||||
gc.Methods = strings.Split(methods, ",")
|
||||
}
|
||||
gcs = append(gcs, gc)
|
||||
} else {
|
||||
// return nil, errors.New("Router information is missing")
|
||||
}
|
||||
} else if strings.HasPrefix(t, objFunc) { // find note
|
||||
t = strings.TrimSpace(strings.TrimPrefix(t, objFunc))
|
||||
note += t
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//defalt
|
||||
if len(gcs) == 0 {
|
||||
gc := genComment{}
|
||||
gc.RouterPath, gc.Methods = b.getDefaultComments(objName, objFunc, num)
|
||||
gcs = append(gcs, gc)
|
||||
}
|
||||
|
||||
// add note 添加注释
|
||||
for i := 0; i < len(gcs); i++ {
|
||||
gcs[i].Note = note
|
||||
}
|
||||
|
||||
return gcs, req, resp
|
||||
}
|
||||
|
||||
// tryGenRegister gen out the Registered config info by struct object,[prepath + bojname.]
|
||||
func (b *_Base) tryGenRegister(router *gin.Engine, cList ...interface{}) bool {
|
||||
modPkg, modFile, isFind := myast.GetModuleInfo(2)
|
||||
if !isFind {
|
||||
return false
|
||||
}
|
||||
|
||||
doc := mydoc.NewDoc(b.groupPath)
|
||||
|
||||
for _, c := range cList {
|
||||
refVal := reflect.ValueOf(c)
|
||||
t := reflect.Indirect(refVal).Type()
|
||||
objPkg := t.PkgPath()
|
||||
objName := t.Name()
|
||||
// fmt.Println(objPkg, objName)
|
||||
|
||||
// find path
|
||||
objFile := myast.EvalSymlinks(modPkg, modFile, objPkg)
|
||||
// fmt.Println(objFile)
|
||||
|
||||
astPkgs, _b := myast.GetAstPkgs(objPkg, objFile) // get ast trees.
|
||||
if _b {
|
||||
imports := myast.AnalysisImport(astPkgs)
|
||||
funMp := myast.GetObjFunMp(astPkgs, objName)
|
||||
// ast.Print(token.NewFileSet(), astPkgs)
|
||||
// fmt.Println(b)
|
||||
|
||||
refTyp := reflect.TypeOf(c)
|
||||
// Install the methods
|
||||
for m := 0; m < refTyp.NumMethod(); m++ {
|
||||
method := refTyp.Method(m)
|
||||
num, _b := b.checkHandlerFunc(method.Type /*.Interface()*/, true)
|
||||
if _b {
|
||||
if sdl, ok := funMp[method.Name]; ok {
|
||||
gcs, req, resp := b.parserComments(sdl, objName, method.Name, imports, objPkg, num)
|
||||
docReq, docResp := b.parserStruct(req, resp, astPkgs, modPkg, modFile)
|
||||
for _, gc := range gcs {
|
||||
doc.AddOne(objName, gc.RouterPath, gc.Methods, gc.Note, docReq, docResp)
|
||||
checkOnceAdd(objName+"."+method.Name, gc.RouterPath, gc.Methods)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doc.GenSwagger(modFile + "/docs/swagger/")
|
||||
doc.GenMarkdown(modFile + "/docs/markdown/")
|
||||
genOutPut(b.outPath, modFile) // generate code
|
||||
return true
|
||||
}
|
||||
|
||||
// register Registered by struct object,[prepath + bojname.]
|
||||
func (b *_Base) register(router *gin.Engine, cList ...interface{}) bool {
|
||||
mp := getInfo()
|
||||
for _, c := range cList {
|
||||
refTyp := reflect.TypeOf(c)
|
||||
refVal := reflect.ValueOf(c)
|
||||
t := reflect.Indirect(refVal).Type()
|
||||
objName := t.Name()
|
||||
|
||||
// Install the methods
|
||||
for m := 0; m < refTyp.NumMethod(); m++ {
|
||||
method := refTyp.Method(m)
|
||||
num, _b := b.checkHandlerFunc(method.Type /*.Interface()*/, true)
|
||||
if _b {
|
||||
if v, ok := mp[objName+"."+method.Name]; ok {
|
||||
for _, v1 := range v {
|
||||
b.registerHandlerObj(router, v1.Methods, buildRelativePath(b.groupPath, v1.RouterPath), method.Func, refVal)
|
||||
}
|
||||
} else { // not find using default case
|
||||
routerPath, methods := b.getDefaultComments(objName, method.Name, num)
|
||||
b.registerHandlerObj(router, methods, buildRelativePath(b.groupPath, routerPath), method.Func, refVal)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *_Base) getDefaultComments(objName, objFunc string, num int) (routerPath string, methods []string) {
|
||||
methods = []string{"get"}
|
||||
if num == 2 { // parm 2 , post default
|
||||
methods = []string{"post"}
|
||||
}
|
||||
|
||||
if b.isBigCamel { // big camel style.大驼峰
|
||||
routerPath = objName + "." + objFunc
|
||||
} else {
|
||||
routerPath = mybigcamel.UnMarshal(objName) + "." + mybigcamel.UnMarshal(objFunc)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// registerHandlerObj Multiple registration methods.获取并过滤要绑定的参数
|
||||
func (b *_Base) registerHandlerObj(router *gin.Engine, httpMethod []string, relativePath string, tvl, obj reflect.Value) error {
|
||||
call := b.handlerFuncObj(tvl, obj)
|
||||
|
||||
for _, v := range httpMethod {
|
||||
// method := strings.ToUpper(v)
|
||||
// switch method{
|
||||
// case "ANY":
|
||||
// router.Any(relativePath,list...)
|
||||
// default:
|
||||
// router.Handle(method,relativePath,list...)
|
||||
// }
|
||||
// or
|
||||
switch strings.ToUpper(v) {
|
||||
case "POST":
|
||||
router.POST(relativePath, call)
|
||||
case "GET":
|
||||
router.GET(relativePath, call)
|
||||
case "DELETE":
|
||||
router.DELETE(relativePath, call)
|
||||
case "PATCH":
|
||||
router.PATCH(relativePath, call)
|
||||
case "PUT":
|
||||
router.PUT(relativePath, call)
|
||||
case "OPTIONS":
|
||||
router.OPTIONS(relativePath, call)
|
||||
case "HEAD":
|
||||
router.HEAD(relativePath, call)
|
||||
case "ANY":
|
||||
router.Any(relativePath, call)
|
||||
default:
|
||||
return errors.Errorf("method:[%v] not support", httpMethod)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
54
common_test.go
Normal file
54
common_test.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package ginrpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
)
|
||||
|
||||
// ReqTest req test
|
||||
type ReqTest struct {
|
||||
AccessToken string `json:"access_token"` // access_token
|
||||
UserName string `json:"user_name" binding:"required"` // user name
|
||||
Password string `json:"password"` // password
|
||||
}
|
||||
|
||||
func TestFun(t *testing.T) {
|
||||
ginrpc := Default()
|
||||
ginrpc.HandlerFunc(func(c *gin.Context) {
|
||||
fmt.Println(c.Params)
|
||||
c.String(200, "ok")
|
||||
})
|
||||
|
||||
ginrpc.HandlerFunc(func(c *api.Context) {
|
||||
fmt.Println(c.Params)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
})
|
||||
|
||||
ginrpc.HandlerFunc(func(c *api.Context, req *ReqTest) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
})
|
||||
|
||||
ginrpc.HandlerFunc(func(c *gin.Context, req ReqTest) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
|
||||
c.JSON(http.StatusOK, req)
|
||||
})
|
||||
|
||||
ginrpc.HandlerFunc(func(c *gin.Context, req ReqTest) (*ReqTest, error) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
|
||||
return &req, nil
|
||||
})
|
||||
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
// router := gin.Default()
|
||||
// router.Run(":8080")
|
||||
}
|
71
def.go
Normal file
71
def.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package ginrpc
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
)
|
||||
|
||||
/*
|
||||
Description: Support three types of interfaces
|
||||
func(*gin.Context) go-gin raw interface
|
||||
func(*Context) Custom context type
|
||||
func(*Context,req) Custom context type with request request request parameters
|
||||
*/
|
||||
|
||||
func _fun1(*gin.Context) {}
|
||||
func _fun2(*api.Context) {}
|
||||
func _fun3(*api.Context, interface{}) {}
|
||||
|
||||
// NewAPIFunc Custom context support
|
||||
type NewAPIFunc func(*gin.Context) interface{}
|
||||
|
||||
// parmInfo 参数类型描述
|
||||
type parmInfo struct {
|
||||
Pkg string // 包名
|
||||
Type string // 类型
|
||||
Import string // import 包
|
||||
}
|
||||
|
||||
// store the comment for the controller method. 生成注解路由
|
||||
type genComment struct {
|
||||
RouterPath string
|
||||
Note string // 注释
|
||||
Methods []string
|
||||
}
|
||||
|
||||
// router style list.路由规则列表
|
||||
type genRouterInfo struct {
|
||||
genComment
|
||||
HandFunName string
|
||||
}
|
||||
|
||||
type genInfo struct {
|
||||
List []genRouterInfo
|
||||
Tm int64 //genout time
|
||||
}
|
||||
|
||||
// // router style list.路由规则列表
|
||||
// type genRouterList struct {
|
||||
// list []genRouterInfo
|
||||
// }
|
||||
|
||||
var (
|
||||
// Precompute the reflect type for error. Can't use error directly
|
||||
// because Typeof takes an empty interface value. This is annoying.
|
||||
typeOfError = reflect.TypeOf((*error)(nil)).Elem()
|
||||
|
||||
genTemp = `
|
||||
package {{.PkgName}}
|
||||
|
||||
import (
|
||||
"github.com/xxjwxc/ginrpc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
ginrpc.SetVersion({{.Tm}})
|
||||
{{range .List}}ginrpc.AddGenOne("{{.HandFunName}}", "{{.RouterPath}}", []string{ {{GetStringList .Methods}} })
|
||||
{{end}} }
|
||||
`
|
||||
)
|
53
example.go
53
example.go
@@ -1,53 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xie1xiao1jun/ginrpc/base"
|
||||
"github.com/xie1xiao1jun/ginrpc/base/api"
|
||||
)
|
||||
|
||||
type ReqTest struct {
|
||||
Access_token string `json:"access_token"` //access_token
|
||||
UserName string `json:"user_name" binding:"required"` //用户名
|
||||
Password string `json:"password"` //新密码
|
||||
}
|
||||
|
||||
//TestFun1 gin 默认的函数回调地址
|
||||
func TestFun1(c *gin.Context) {
|
||||
fmt.Println(c.Params)
|
||||
c.String(200, "ok")
|
||||
}
|
||||
|
||||
//TestFun2 自定义context的函数回调地址
|
||||
func TestFun2(c *api.Context) {
|
||||
fmt.Println(c.Params)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
//TestFun3 带自定义context跟已解析的req参数回调方式
|
||||
func TestFun3(c *api.Context, req *ReqTest) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
//TestFun3 带自定义context跟已解析的req参数回调方式
|
||||
func TestFun4(c *gin.Context, req ReqTest) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
|
||||
c.JSON(http.StatusOK, req)
|
||||
}
|
||||
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
router.POST("/test1", base.GetHandlerFunc(TestFun1))
|
||||
router.POST("/test2", base.GetHandlerFunc(TestFun2))
|
||||
router.POST("/test3", base.GetHandlerFunc(TestFun3))
|
||||
router.POST("/test4", base.GetHandlerFunc(TestFun4))
|
||||
|
||||
router.Run(":8080")
|
||||
}
|
156
gen.go
Normal file
156
gen.go
Normal file
@@ -0,0 +1,156 @@
|
||||
package ginrpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/xxjwxc/public/serializing"
|
||||
"github.com/xxjwxc/public/tools"
|
||||
)
|
||||
|
||||
var _mu sync.Mutex // protects the serviceMap
|
||||
var _once sync.Once
|
||||
var _genInfo genInfo
|
||||
var _genInfoCnf genInfo
|
||||
|
||||
func init() {
|
||||
data, err := ioutil.ReadFile(tools.GetModelPath() + "/gen_router.data")
|
||||
if err == nil {
|
||||
serializing.Decode(data, &_genInfoCnf) // gob de serialize 反序列化
|
||||
}
|
||||
}
|
||||
|
||||
// AddGenOne add one to base case
|
||||
func AddGenOne(handFunName, routerPath string, methods []string) {
|
||||
_mu.Lock()
|
||||
defer _mu.Unlock()
|
||||
_genInfo.List = append(_genInfo.List, genRouterInfo{
|
||||
HandFunName: handFunName,
|
||||
genComment: genComment{
|
||||
RouterPath: routerPath,
|
||||
Methods: methods,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// SetVersion user timestamp to replace version
|
||||
func SetVersion(tm int64) {
|
||||
_mu.Lock()
|
||||
defer _mu.Unlock()
|
||||
_genInfo.Tm = tm
|
||||
}
|
||||
|
||||
func checkOnceAdd(handFunName, routerPath string, methods []string) {
|
||||
_once.Do(func() {
|
||||
_mu.Lock()
|
||||
defer _mu.Unlock()
|
||||
_genInfo.Tm = time.Now().Unix()
|
||||
_genInfo.List = []genRouterInfo{} // reset
|
||||
})
|
||||
|
||||
AddGenOne(handFunName, routerPath, methods)
|
||||
}
|
||||
|
||||
// GetStringList format string
|
||||
func GetStringList(list []string) string {
|
||||
return `"` + strings.Join(list, `","`) + `"`
|
||||
}
|
||||
|
||||
func genOutPut(outDir, modFile string) {
|
||||
_mu.Lock()
|
||||
defer _mu.Unlock()
|
||||
|
||||
if len(outDir) == 0 {
|
||||
outDir = modFile + "/routers/"
|
||||
}
|
||||
pkgName := getPkgName(outDir)
|
||||
|
||||
_genInfo.Tm = time.Now().Unix()
|
||||
|
||||
data := struct {
|
||||
genInfo
|
||||
PkgName string
|
||||
}{
|
||||
genInfo: _genInfo,
|
||||
PkgName: pkgName,
|
||||
}
|
||||
|
||||
tmpl, err := template.New("gen_out").Funcs(template.FuncMap{"GetStringList": GetStringList}).Parse(genTemp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
tmpl.Execute(&buf, data)
|
||||
tools.WriteFile(outDir+"gen_router.go", []string{buf.String()}, true)
|
||||
|
||||
// format
|
||||
exec.Command("gofmt", "-l", "-w", outDir).Output()
|
||||
|
||||
// gob serialize 序列化
|
||||
_data, _ := serializing.Encode(_genInfo)
|
||||
flag := os.O_CREATE | os.O_WRONLY | os.O_TRUNC
|
||||
f, err := os.OpenFile(tools.GetModelPath()+"/gen_router.data", flag, 0666)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
f.Write(_data)
|
||||
}
|
||||
|
||||
func getPkgName(dir string) string {
|
||||
dir = strings.Replace(dir, "\\", "/", -1)
|
||||
dir = strings.TrimRight(dir, "/")
|
||||
|
||||
var pkgName string
|
||||
list := strings.Split(dir, "/")
|
||||
if len(list) > 0 {
|
||||
pkgName = list[len(list)-1]
|
||||
}
|
||||
|
||||
if len(pkgName) == 0 || pkgName == "." {
|
||||
list = strings.Split(tools.GetModelPath(), "/")
|
||||
if len(list) > 0 {
|
||||
pkgName = list[len(list)-1]
|
||||
}
|
||||
}
|
||||
|
||||
return pkgName
|
||||
}
|
||||
|
||||
func getInfo() map[string][]genRouterInfo {
|
||||
_mu.Lock()
|
||||
defer _mu.Unlock()
|
||||
|
||||
genInfo := _genInfo
|
||||
if _genInfoCnf.Tm > genInfo.Tm { // config to update more than coding
|
||||
genInfo = _genInfoCnf
|
||||
}
|
||||
|
||||
mp := make(map[string][]genRouterInfo, len(genInfo.List))
|
||||
for _, v := range genInfo.List {
|
||||
tmp := v
|
||||
mp[tmp.HandFunName] = append(mp[tmp.HandFunName], tmp)
|
||||
}
|
||||
return mp
|
||||
}
|
||||
|
||||
func buildRelativePath(prepath, routerPath string) string {
|
||||
if strings.HasSuffix(prepath, "/") {
|
||||
if strings.HasPrefix(routerPath, "/") {
|
||||
return prepath + strings.TrimPrefix(routerPath, "/")
|
||||
}
|
||||
return prepath + routerPath
|
||||
}
|
||||
|
||||
if strings.HasPrefix(routerPath, "/") {
|
||||
return prepath + routerPath
|
||||
}
|
||||
|
||||
return prepath + "/" + routerPath
|
||||
}
|
BIN
gen_router.data
Normal file
BIN
gen_router.data
Normal file
Binary file not shown.
203
ginrpc.go
Normal file
203
ginrpc.go
Normal file
@@ -0,0 +1,203 @@
|
||||
package ginrpc
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
"github.com/xxjwxc/public/errors"
|
||||
)
|
||||
|
||||
// _Base base struct
|
||||
type _Base struct {
|
||||
// tag int
|
||||
isBigCamel bool // big camel style.大驼峰命名规则
|
||||
isDev bool // if is development
|
||||
apiFun NewAPIFunc
|
||||
apiType reflect.Type
|
||||
router *gin.Engine
|
||||
groupPath string // group path.添加路由前缀
|
||||
outPath string // output path.输出目录
|
||||
}
|
||||
|
||||
// Option overrides behavior of Connect.
|
||||
type Option interface {
|
||||
apply(*_Base)
|
||||
}
|
||||
|
||||
type optionFunc func(*_Base)
|
||||
|
||||
func (f optionFunc) apply(o *_Base) {
|
||||
f(o)
|
||||
}
|
||||
|
||||
// WithCtx use custom context.设置自定义context
|
||||
func WithCtx(middleware NewAPIFunc) Option {
|
||||
return optionFunc(func(o *_Base) {
|
||||
o.Model(middleware)
|
||||
})
|
||||
}
|
||||
|
||||
// WithDebug set build is development.设置debug模式(默认debug模式)
|
||||
func WithDebug(b bool) Option {
|
||||
return optionFunc(func(o *_Base) {
|
||||
o.Dev(b)
|
||||
})
|
||||
}
|
||||
|
||||
// WithBigCamel set build is BigCamel.是否大驼峰模式
|
||||
func WithBigCamel(b bool) Option {
|
||||
return optionFunc(func(o *_Base) {
|
||||
o.isBigCamel = b
|
||||
})
|
||||
}
|
||||
|
||||
// WithGroup Add route prefix.添加路由前缀
|
||||
func WithGroup(prepath string) Option {
|
||||
return optionFunc(func(o *_Base) {
|
||||
o.Group(prepath)
|
||||
})
|
||||
}
|
||||
|
||||
// Default new op obj
|
||||
func Default() *_Base {
|
||||
b := new(_Base)
|
||||
b.Model(api.NewAPIFunc)
|
||||
b.Dev(true)
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// New new customized base
|
||||
func New(opts ...Option) *_Base {
|
||||
b := Default() // default option
|
||||
|
||||
for _, o := range opts {
|
||||
o.apply(b)
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Dev set build is development
|
||||
func (b *_Base) Dev(isDev bool) {
|
||||
b.isDev = isDev
|
||||
}
|
||||
|
||||
// Model use custom context
|
||||
func (b *_Base) Model(middleware NewAPIFunc) *_Base {
|
||||
if middleware == nil { // default middleware
|
||||
middleware = api.NewAPIFunc
|
||||
}
|
||||
|
||||
b.apiFun = middleware // save callback
|
||||
|
||||
rt := reflect.TypeOf(middleware(&gin.Context{}))
|
||||
if rt == nil || rt.Kind() != reflect.Ptr {
|
||||
panic("need pointer")
|
||||
}
|
||||
b.apiType = rt
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Group creates a new router group. You should add all the routes that have common middlewares or the same path prefix.
|
||||
// For example, all the routes that use a common middleware for authorization could be grouped.
|
||||
// Last : you can us gin.Group replace this also (添加路由前缀,也可以调用gin.Group来设置)
|
||||
func (b *_Base) Group(prepath string) *_Base {
|
||||
prepath = strings.Replace(prepath, "\\", "/", -1)
|
||||
if !strings.HasSuffix(prepath, "/") {
|
||||
prepath += "/"
|
||||
}
|
||||
b.groupPath = prepath
|
||||
return b
|
||||
}
|
||||
|
||||
// Register Registered by struct object,[prepath + bojname.]
|
||||
func (b *_Base) Register(router *gin.Engine, cList ...interface{}) bool {
|
||||
if b.isDev {
|
||||
b.tryGenRegister(router, cList...)
|
||||
}
|
||||
|
||||
return b.register(router, cList...)
|
||||
}
|
||||
|
||||
// RegisterHandlerFunc Multiple registration methods.获取并过滤要绑定的参数
|
||||
func (b *_Base) RegisterHandlerFunc(router *gin.Engine, httpMethod []string, relativePath string, handlerFuncs ...interface{}) error {
|
||||
list := make([]gin.HandlerFunc, 0, len(handlerFuncs))
|
||||
for _, call := range handlerFuncs {
|
||||
list = append(list, b.HandlerFunc(call))
|
||||
}
|
||||
|
||||
for _, v := range httpMethod {
|
||||
// method := strings.ToUpper(v)
|
||||
// switch method{
|
||||
// case "ANY":
|
||||
// router.Any(relativePath,list...)
|
||||
// default:
|
||||
// router.Handle(method,relativePath,list...)
|
||||
// }
|
||||
// or
|
||||
switch strings.ToUpper(v) {
|
||||
case "POST":
|
||||
router.POST(relativePath, list...)
|
||||
case "GET":
|
||||
router.GET(relativePath, list...)
|
||||
case "DELETE":
|
||||
router.DELETE(relativePath, list...)
|
||||
case "PATCH":
|
||||
router.PATCH(relativePath, list...)
|
||||
case "PUT":
|
||||
router.PUT(relativePath, list...)
|
||||
case "OPTIONS":
|
||||
router.OPTIONS(relativePath, list...)
|
||||
case "HEAD":
|
||||
router.HEAD(relativePath, list...)
|
||||
case "ANY":
|
||||
router.Any(relativePath, list...)
|
||||
default:
|
||||
return errors.Errorf("method:[%v] not support", httpMethod)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HandlerFunc Get and filter the parameters to be bound
|
||||
func (b *_Base) HandlerFunc(handlerFunc interface{}) gin.HandlerFunc { // 获取并过滤要绑定的参数
|
||||
typ := reflect.ValueOf(handlerFunc).Type()
|
||||
if typ.NumIn() == 1 { // Parameter checking 参数检查
|
||||
ctxType := typ.In(0)
|
||||
|
||||
// go-gin default method
|
||||
if ctxType == reflect.TypeOf(&gin.Context{}) {
|
||||
return handlerFunc.(func(*gin.Context))
|
||||
}
|
||||
|
||||
// Customized context . 自定义的context
|
||||
if ctxType == b.apiType {
|
||||
method := reflect.ValueOf(handlerFunc)
|
||||
return func(c *gin.Context) {
|
||||
method.Call([]reflect.Value{reflect.ValueOf(b.apiFun(c))})
|
||||
}
|
||||
}
|
||||
|
||||
panic("method " + runtime.FuncForPC(reflect.ValueOf(handlerFunc).Pointer()).Name() + " not support!")
|
||||
}
|
||||
|
||||
// Custom context type with request parameters .自定义的context类型,带request 请求参数
|
||||
call, err := b.getCallFunc3(reflect.ValueOf(handlerFunc))
|
||||
if err != nil { // Direct reporting error.
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return call
|
||||
}
|
||||
|
||||
// CheckHandlerFunc Judge whether to match rules
|
||||
func (b *_Base) CheckHandlerFunc(handlerFunc interface{}) (int, bool) { // 判断是否匹配规则,返回参数个数
|
||||
typ := reflect.ValueOf(handlerFunc).Type()
|
||||
return b.checkHandlerFunc(typ, false)
|
||||
}
|
116
ginrpc_test.go
Normal file
116
ginrpc_test.go
Normal file
@@ -0,0 +1,116 @@
|
||||
package ginrpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
)
|
||||
|
||||
func TestModelObj(t *testing.T) {
|
||||
// base := New(WithCtx(func(c *gin.Context) interface{} {
|
||||
// return api.NewCtx(c)
|
||||
// }))
|
||||
|
||||
// router := gin.Default()
|
||||
// base.Register(router, new(Hello))
|
||||
}
|
||||
|
||||
func TestModelFunc(t *testing.T) {
|
||||
// base := Default()
|
||||
// base.Model(func(c *gin.Context) interface{} {
|
||||
// return api.NewCtx(c)
|
||||
// })
|
||||
base := New(WithCtx(func(c *gin.Context) interface{} {
|
||||
return api.NewCtx(c)
|
||||
}))
|
||||
|
||||
router := gin.Default()
|
||||
base.RegisterHandlerFunc(router, []string{"post", "get"}, "/test", testFun1)
|
||||
router.POST("/test1", base.HandlerFunc(testFun1))
|
||||
router.POST("/test2", base.HandlerFunc(testFun2))
|
||||
router.POST("/test3", base.HandlerFunc(testFun3))
|
||||
router.POST("/test4", base.HandlerFunc(testFun4))
|
||||
|
||||
// router.Run(":8080")
|
||||
}
|
||||
|
||||
// ReqTest test req
|
||||
type ReqTest1 struct {
|
||||
AccessToken string `json:"access_token"` // access_token
|
||||
UserName string `json:"user_name" binding:"required"` // user name
|
||||
Password string `json:"password"` // password
|
||||
}
|
||||
|
||||
// testFun1 Default function callback address on gin
|
||||
func testFun1(c *gin.Context) { // gin 默认的函数回调地址
|
||||
fmt.Println(c.Params)
|
||||
c.String(200, "ok")
|
||||
}
|
||||
|
||||
// testFun2 Customize the function callback address of context
|
||||
func testFun2(c *api.Context) { // 自定义context的函数回调地址
|
||||
fmt.Println(c.Params)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
// testFun3 Callback with custom context and parsed req parameters
|
||||
func testFun3(c *api.Context, req *ReqTest1) { // 带自定义context跟已解析的req参数回调方式
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
// testFun4 Callback with go-gin context and parsed req parameters
|
||||
func testFun4(c *gin.Context, req ReqTest1) { // 带默认context跟已解析的req参数回调方式
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
|
||||
c.JSON(http.StatusOK, req)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// Hello ...
|
||||
type Hello struct {
|
||||
Index int
|
||||
}
|
||||
|
||||
// HelloS ...
|
||||
// @Router /block [post,get]
|
||||
func (s *Hello) HelloS(c *api.Context, req *ReqTest1) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
// HelloS2 ...
|
||||
func (s *Hello) HelloS2(c *api.Context, req *ReqTest1) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
fmt.Println(s.Index)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
// HelloS3 ...
|
||||
func (s *Hello) HelloS3(c *api.Context, req *ReqTest1) (*ReqTest1, error) {
|
||||
fmt.Println(c.Params)
|
||||
fmt.Println(req)
|
||||
fmt.Println(s.Index)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func TestObj(t *testing.T) {
|
||||
base := New(WithCtx(func(c *gin.Context) interface{} {
|
||||
return api.NewCtx(c)
|
||||
}), WithDebug(true), WithGroup("xxjwxc"), WithBigCamel(true))
|
||||
|
||||
router := gin.Default()
|
||||
h := new(Hello)
|
||||
h.Index = 123
|
||||
base.Register(router, h) //, new(api.Hello))
|
||||
// router.Run(":8080")
|
||||
}
|
24
go.mod
Normal file
24
go.mod
Normal file
@@ -0,0 +1,24 @@
|
||||
module github.com/xxjwxc/ginrpc
|
||||
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
|
||||
github.com/gin-gonic/gin v1.5.1-0.20191220060158-9b3477ef9d2c
|
||||
github.com/go-playground/validator/v10 v10.0.1
|
||||
github.com/golang/protobuf v1.3.5 // indirect
|
||||
github.com/gookit/color v1.2.3 // indirect
|
||||
github.com/json-iterator/go v1.1.9 // indirect
|
||||
github.com/kr/pretty v0.2.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.11 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
|
||||
github.com/stretchr/testify v1.5.1 // indirect
|
||||
github.com/xxjwxc/public v0.0.0-20200329130606-2b6bdf6dc342
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
||||
gopkg.in/yaml.v2 v2.2.8 // indirect
|
||||
)
|
||||
|
||||
// replace github.com/xxjwxc/public => ../public
|
241
go.sum
Normal file
241
go.sum
Normal file
@@ -0,0 +1,241 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
|
||||
github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/ant0ine/go-json-rest v3.3.2+incompatible h1:nBixrkLFiDNAW0hauKDLc8yJI6XfrQumWvytE1Hk14E=
|
||||
github.com/ant0ine/go-json-rest v3.3.2+incompatible/go.mod h1:q6aCt0GfU6LhpBsnZ/2U+mwe+0XB5WStbmwyoPfc+sk=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/astaxie/beego v1.7.1/go.mod h1:0R4++1tUqERR0WYFWdfkcrsyoVBCG4DgpDGokT3yb+U=
|
||||
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=
|
||||
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20160117192205-fb1f79c6b65a/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/ezbuy/tgen v0.0.0-20180109020500-95ef13895032/go.mod h1:OeW1N0acAlRaGTlOG8jRZZUKEtyiGa0qvD+lWNWb9vs=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.1.4/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
|
||||
github.com/gin-gonic/gin v1.5.1-0.20191220060158-9b3477ef9d2c h1:8WkfPHLTNm7yUY23qDL/Oozm6+mr7VByegtmF7ztRmo=
|
||||
github.com/gin-gonic/gin v1.5.1-0.20191220060158-9b3477ef9d2c/go.mod h1:knUb66iw5OZMlLM8onkhc25EdI6LpHWZKWVhXumCspQ=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.0.1 h1:QgDDZpXlR/L3atIL2PbFt0TpazbtN7N6PxTGcgcyEUg=
|
||||
github.com/go-playground/validator/v10 v10.0.1/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v0.0.0-20161117033126-8ee79997227b/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v2.0.1-0.20180627144507-2cd21d9966bf+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/gookit/color v1.1.7 h1:WR5I/mhSHzemW2DzG54hTsUb7OzaREvkcmUG4/WST4Q=
|
||||
github.com/gookit/color v1.1.7/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
|
||||
github.com/gookit/color v1.2.3 h1:2Si0/JAEE2+1hkNYuTszu54Ti9wfp+M4JNNrknf9/D0=
|
||||
github.com/gookit/color v1.2.3/go.mod h1:AhIE+pS6D4Ql0SQWbBeXPHw7gY0/sjHoA4s/n1KB7xg=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/jander/golog v0.0.0-20150917071935-954a5be801fc/go.mod h1:uWhWXOR4dpfk9J8fegnMY7sP2GFXxe3PFI9Ps+TRXJs=
|
||||
github.com/jinzhu/gorm v1.9.11/go.mod h1:bu/pK8szGZ2puuErfU0RwyeNdsf3e6nCX/noXaVxkfw=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jroimartin/gocui v0.4.0/go.mod h1:7i7bbj99OgFHzo7kB2zPb8pXLqMBSQegY7azfqXMkyY=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kardianos/service v1.0.1-0.20191017145738-4df36c9fc1c6/go.mod h1:8CzDhVuCuugtsHyZoTvsOBuvonN/UDBvl0kH+BUxvbo=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||
github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739/go.mod h1:zUx1mhth20V3VKgL5jbd1BSQcW4Fy6Qs4PZvQwRFwzM=
|
||||
github.com/mattn/go-isatty v0.0.0-20161123143637-30a891c33c7c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/muesli/cache2go v0.0.0-20191019095710-4098a3aa8c94/go.mod h1:414R+qZrt4f9S2TO/s6YVQMNAXR2KdwqQ7pW+O4oYzU=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.0.3/go.mod h1:oDab7q8XCYMRlcrBnaY/7B1eOectbvj6B1UPBT+p5jo=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nsf/termbox-go v0.0.0-20191229070316-58d4fcbce2a7/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
|
||||
github.com/olivere/elastic v6.2.26+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/silenceper/wechat v1.2.3/go.mod h1:sEqmYpYrwwMCXUSzTaxcA78+fd0p+srrj8qRkOnpbLQ=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/xxjwxc/public v0.0.0-20200329130606-2b6bdf6dc342 h1:qHG/g/AaeBKx+8XiGr5QTYIOoTojfea9ikTCqdYuAEs=
|
||||
github.com/xxjwxc/public v0.0.0-20200329130606-2b6bdf6dc342/go.mod h1:8c3gMuRJkSGX3DpDvxU0fWfEEbuMi1LxPsKEBp97dnc=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c h1:uOCk1iQW6Vc18bnC13MfzScl+wdKBmM9Y9kU7Z83/lw=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20191125084936-ffdde1057850/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191104094858-e8c54fb511f6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/eapache/queue.v1 v1.1.0/go.mod h1:wNtmx1/O7kZSR9zNT1TTOJ7GLpm3Vn7srzlfylFbQwU=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||
gopkg.in/go-playground/validator.v8 v8.18.1/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
|
||||
gopkg.in/go-with/wxpay.v1 v1.3.0/go.mod h1:12lWy92n19pAUSSE3BrOiEZbWRkl+9tneOd/aU/LU6g=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
BIN
image/ginrpc.gif
Normal file
BIN
image/ginrpc.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
BIN
image/ginrpc_doc.gif
Normal file
BIN
image/ginrpc_doc.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 MiB |
12
routers/gen_router.go
Normal file
12
routers/gen_router.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package routers
|
||||
|
||||
import (
|
||||
"github.com/xxjwxc/ginrpc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
ginrpc.SetVersion(1583837408)
|
||||
ginrpc.AddGenOne("Hello.HelloS", "/block", []string{"post", "get"})
|
||||
ginrpc.AddGenOne("Hello.HelloS2", "Hello.HelloS2", []string{"post"})
|
||||
ginrpc.AddGenOne("Hello.HelloS3", "Hello.HelloS3", []string{"post"})
|
||||
}
|
BIN
sample/.DS_Store
vendored
Normal file
BIN
sample/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
sample/gen_router.data
Normal file
BIN
sample/gen_router.data
Normal file
Binary file not shown.
3
sample/ginweb/.vscode/settings.json
vendored
Normal file
3
sample/ginweb/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"go.inferGopath": false
|
||||
}
|
BIN
sample/ginweb/gen_router.data
Normal file
BIN
sample/ginweb/gen_router.data
Normal file
Binary file not shown.
11
sample/ginweb/go.mod
Normal file
11
sample/ginweb/go.mod
Normal file
@@ -0,0 +1,11 @@
|
||||
module ginweb
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.6.2
|
||||
github.com/xxjwxc/ginrpc v0.0.0-20200329131906-b768ef9136c0
|
||||
golang.org/x/sys v0.0.0-20200327173247-9dae0f8f5775 // indirect
|
||||
)
|
||||
|
||||
// replace github.com/xxjwxc/ginrpc => ../../
|
252
sample/ginweb/go.sum
Normal file
252
sample/ginweb/go.sum
Normal file
@@ -0,0 +1,252 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
|
||||
github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/ant0ine/go-json-rest v3.3.2+incompatible h1:nBixrkLFiDNAW0hauKDLc8yJI6XfrQumWvytE1Hk14E=
|
||||
github.com/ant0ine/go-json-rest v3.3.2+incompatible/go.mod h1:q6aCt0GfU6LhpBsnZ/2U+mwe+0XB5WStbmwyoPfc+sk=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/astaxie/beego v1.7.1/go.mod h1:0R4++1tUqERR0WYFWdfkcrsyoVBCG4DgpDGokT3yb+U=
|
||||
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=
|
||||
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20160117192205-fb1f79c6b65a/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/ezbuy/tgen v0.0.0-20180109020500-95ef13895032/go.mod h1:OeW1N0acAlRaGTlOG8jRZZUKEtyiGa0qvD+lWNWb9vs=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.1.4/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
|
||||
github.com/gin-gonic/gin v1.5.1-0.20191220060158-9b3477ef9d2c h1:8WkfPHLTNm7yUY23qDL/Oozm6+mr7VByegtmF7ztRmo=
|
||||
github.com/gin-gonic/gin v1.5.1-0.20191220060158-9b3477ef9d2c/go.mod h1:knUb66iw5OZMlLM8onkhc25EdI6LpHWZKWVhXumCspQ=
|
||||
github.com/gin-gonic/gin v1.6.2 h1:88crIK23zO6TqlQBt+f9FrPJNKm9ZEr7qjp9vl/d5TM=
|
||||
github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.0.1 h1:QgDDZpXlR/L3atIL2PbFt0TpazbtN7N6PxTGcgcyEUg=
|
||||
github.com/go-playground/validator/v10 v10.0.1/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
||||
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
|
||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v0.0.0-20161117033126-8ee79997227b/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v2.0.1-0.20180627144507-2cd21d9966bf+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/gookit/color v1.1.7 h1:WR5I/mhSHzemW2DzG54hTsUb7OzaREvkcmUG4/WST4Q=
|
||||
github.com/gookit/color v1.1.7/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
|
||||
github.com/gookit/color v1.2.3 h1:2Si0/JAEE2+1hkNYuTszu54Ti9wfp+M4JNNrknf9/D0=
|
||||
github.com/gookit/color v1.2.3/go.mod h1:AhIE+pS6D4Ql0SQWbBeXPHw7gY0/sjHoA4s/n1KB7xg=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/jander/golog v0.0.0-20150917071935-954a5be801fc/go.mod h1:uWhWXOR4dpfk9J8fegnMY7sP2GFXxe3PFI9Ps+TRXJs=
|
||||
github.com/jinzhu/gorm v1.9.11/go.mod h1:bu/pK8szGZ2puuErfU0RwyeNdsf3e6nCX/noXaVxkfw=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jroimartin/gocui v0.4.0/go.mod h1:7i7bbj99OgFHzo7kB2zPb8pXLqMBSQegY7azfqXMkyY=
|
||||
github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kardianos/service v1.0.1-0.20191017145738-4df36c9fc1c6/go.mod h1:8CzDhVuCuugtsHyZoTvsOBuvonN/UDBvl0kH+BUxvbo=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||
github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739/go.mod h1:zUx1mhth20V3VKgL5jbd1BSQcW4Fy6Qs4PZvQwRFwzM=
|
||||
github.com/mattn/go-isatty v0.0.0-20161123143637-30a891c33c7c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/muesli/cache2go v0.0.0-20191019095710-4098a3aa8c94/go.mod h1:414R+qZrt4f9S2TO/s6YVQMNAXR2KdwqQ7pW+O4oYzU=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.0.3/go.mod h1:oDab7q8XCYMRlcrBnaY/7B1eOectbvj6B1UPBT+p5jo=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nsf/termbox-go v0.0.0-20191229070316-58d4fcbce2a7/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
|
||||
github.com/olivere/elastic v6.2.26+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/silenceper/wechat v1.2.3/go.mod h1:sEqmYpYrwwMCXUSzTaxcA78+fd0p+srrj8qRkOnpbLQ=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/xxjwxc/public v0.0.0-20200329130606-2b6bdf6dc342 h1:qHG/g/AaeBKx+8XiGr5QTYIOoTojfea9ikTCqdYuAEs=
|
||||
github.com/xxjwxc/public v0.0.0-20200329130606-2b6bdf6dc342/go.mod h1:8c3gMuRJkSGX3DpDvxU0fWfEEbuMi1LxPsKEBp97dnc=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20191125084936-ffdde1057850/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191104094858-e8c54fb511f6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200327173247-9dae0f8f5775 h1:TC0v2RSO1u2kn1ZugjrFXkRZAEaqMN/RW+OTZkBzmLE=
|
||||
golang.org/x/sys v0.0.0-20200327173247-9dae0f8f5775/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/eapache/queue.v1 v1.1.0/go.mod h1:wNtmx1/O7kZSR9zNT1TTOJ7GLpm3Vn7srzlfylFbQwU=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||
gopkg.in/go-playground/validator.v8 v8.18.1/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
|
||||
gopkg.in/go-with/wxpay.v1 v1.3.0/go.mod h1:12lWy92n19pAUSSE3BrOiEZbWRkl+9tneOd/aU/LU6g=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
103
sample/ginweb/main.go
Normal file
103
sample/ginweb/main.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
_ "ginweb/routers" // debug模式需要添加[mod]/routers 注册注解路由
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
)
|
||||
|
||||
// ReqTest demo struct
|
||||
type ReqTest struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
UserName string `json:"user_name" binding:"required"` // 带校验方式
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
// Hello ...
|
||||
type Hello struct {
|
||||
Index int
|
||||
}
|
||||
|
||||
// Hello 带注解路由(参考beego形式)
|
||||
// @Router /block [post,get]
|
||||
func (s *Hello) Hello(c *api.Context, req *ReqTest) {
|
||||
fmt.Println(req)
|
||||
fmt.Println(s.Index)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
// Hello2 不带注解路由(参数为2默认post)
|
||||
func (s *Hello) Hello2(c *gin.Context, req ReqTest) {
|
||||
fmt.Println(req)
|
||||
fmt.Println(s.Index)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
//Hello3 带自定义context跟已解析的req参数回调方式,err,resp 返回模式
|
||||
func (s *Hello) Hello3(c *gin.Context, req ReqTest) (*ReqTest, error) {
|
||||
fmt.Println(req)
|
||||
//c.JSON(http.StatusOK, req)
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
//TestFun1 gin 默认的函数回调地址
|
||||
func TestFun1(c *gin.Context) {
|
||||
c.String(200, "ok")
|
||||
}
|
||||
|
||||
//TestFun2 自定义context的函数回调地址
|
||||
func TestFun2(c *api.Context) {
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
//TestFun3 带自定义context跟已解析的req参数回调方式
|
||||
func TestFun3(c *api.Context, req *ReqTest) {
|
||||
fmt.Println(req)
|
||||
c.WriteJSON(req)
|
||||
}
|
||||
|
||||
//TestFun4 带自定义context跟已解析的req参数回调方式
|
||||
func TestFun4(c *gin.Context, req ReqTest) {
|
||||
fmt.Println(req)
|
||||
c.JSON(http.StatusOK, req)
|
||||
}
|
||||
|
||||
//TestFun5 带自定义context跟已解析的req参数回调方式,err,resp 返回模式
|
||||
func TestFun5(c *gin.Context, req ReqTest) (ReqTest, error) {
|
||||
fmt.Println(req)
|
||||
//c.JSON(http.StatusOK, req)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//TestFun6 带自定义context跟已解析的req参数回调方式,err,resp 返回模式
|
||||
func TestFun6(c *gin.Context, req ReqTest) (*ReqTest, error) {
|
||||
fmt.Println(req)
|
||||
//c.JSON(http.StatusOK, req)
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
base := ginrpc.New(ginrpc.WithCtx(func(c *gin.Context) interface{} {
|
||||
return api.NewCtx(c)
|
||||
}), ginrpc.WithDebug(true), ginrpc.WithGroup("xxjwxc"))
|
||||
router := gin.Default()
|
||||
|
||||
router.POST("/test5", base.HandlerFunc(TestFun5)) // 函数注册
|
||||
router.POST("/test6", base.HandlerFunc(TestFun6)) // 函数注册
|
||||
|
||||
h := new(Hello)
|
||||
h.Index = 123
|
||||
base.Register(router, h) // 对象注册
|
||||
router.POST("/test1", base.HandlerFunc(TestFun1)) // 函数注册
|
||||
router.POST("/test2", base.HandlerFunc(TestFun2))
|
||||
router.POST("/test3", base.HandlerFunc(TestFun3))
|
||||
router.POST("/test4", base.HandlerFunc(TestFun4))
|
||||
base.RegisterHandlerFunc(router, []string{"post", "get"}, "/test", TestFun1) // 多种请求方式注册
|
||||
|
||||
router.Run(":8080")
|
||||
}
|
12
sample/ginweb/routers/gen_router.go
Normal file
12
sample/ginweb/routers/gen_router.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package routers
|
||||
|
||||
import (
|
||||
"github.com/xxjwxc/ginrpc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
ginrpc.SetVersion(1579966190)
|
||||
ginrpc.AddGenOne("Hello.Hello", "/block", []string{"post", "get"})
|
||||
ginrpc.AddGenOne("Hello.Hello2", "hello.hello2", []string{"post"})
|
||||
ginrpc.AddGenOne("Hello.Hello3", "hello.hello3", []string{"post"})
|
||||
}
|
29
sample/main.go
Normal file
29
sample/main.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
)
|
||||
|
||||
// ReqTest struct test
|
||||
type ReqTest struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
UserName string `json:"user_name" binding:"required"` // 带校验方式
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
//TestFun4 带自定义context跟已解析的req参数回调方式
|
||||
func TestFun4(c *api.Context, req ReqTest) {
|
||||
fmt.Println(req)
|
||||
c.WriteJSON(req)
|
||||
}
|
||||
|
||||
func main() {
|
||||
base := ginrpc.New()
|
||||
router := gin.Default()
|
||||
router.POST("/test4", base.HandlerFunc(TestFun4))
|
||||
router.Run(":8080")
|
||||
}
|
Reference in New Issue
Block a user