GoLang ZipArchive::addPattern

request it (113)
GoLang replacement for PHP's ZipArchive::addPattern [edit | history]

Do you know a GoLang replacement for PHP's ZipArchive::addPattern? Write it!

PHP ZipArchive::addPattern

PHP original manual for ZipArchive::addPattern [ show | php.net ]


(PHP 5 >= 5.3.0, PHP 7, PECL zip >= 1.9.0)

ZipArchive::addPatternAdd files from a directory by PCRE pattern


bool ZipArchive::addPattern ( string $pattern [, string $path = "." [, array $options = array() ]] )

Add files from a directory which match the regular expression pattern. The operation is not recursive. The pattern will be matched against the file name only.



A PCRE pattern against which files will be matched.


The directory that will be scanned. Defaults to the current working directory.


An associative array of options accepted by ZipArchive::addGlob().

Return Values

Returns TRUE on success or FALSE on failure.


Example #1 ZipArchive::addPattern() example

Add all php scripts and text files from current directory

= new ZipArchive();
$ret $zip->open('application.zip'ZipArchive::OVERWRITE);
if (
$ret !== TRUE) {
printf('Failed with code %d'$ret);
} else {
$directory realpath('.');
$options = array('add_path' => 'sources/''remove_path' => $directory);

See Also